Skip to content

Commit

Permalink
Fix fab failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ephraimbuddy committed Jan 15, 2025
1 parent bed2fa1 commit 834f7e1
Showing 1 changed file with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
]

TEST_DAG_IDS = ["test_dag", "test_dag2"]
BUNDLE_NAME = "testing"


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -88,11 +89,14 @@ def _normalize_import_errors(import_errors):


class TestGetImportErrorEndpoint(TestBaseImportError):
def test_should_raise_403_forbidden_without_dag_read(self, session):
def test_should_raise_403_forbidden_without_dag_read(self, configure_testing_dag_bundle, session):
with configure_testing_dag_bundle("/tmp"):
DagBundlesManager().sync_bundles_to_db()
import_error = ParseImportError(
filename="Lorem_ipsum.py",
stacktrace="Lorem ipsum",
timestamp=timezone.parse(self.timestamp, timezone="UTC"),
bundle_name=BUNDLE_NAME,
)
session.add(import_error)
session.commit()
Expand All @@ -103,13 +107,16 @@ def test_should_raise_403_forbidden_without_dag_read(self, session):

assert response.status_code == 403

def test_should_return_200_with_single_dag_read(self, session):
dag_model = DagModel(dag_id=TEST_DAG_IDS[0], fileloc="Lorem_ipsum.py")
def test_should_return_200_with_single_dag_read(self, session, configure_testing_dag_bundle):
with configure_testing_dag_bundle("/tmp"):
DagBundlesManager().sync_bundles_to_db()
dag_model = DagModel(dag_id=TEST_DAG_IDS[0], fileloc="Lorem_ipsum.py", bundle_name=BUNDLE_NAME)
session.add(dag_model)
import_error = ParseImportError(
filename="Lorem_ipsum.py",
stacktrace="Lorem ipsum",
timestamp=timezone.parse(self.timestamp, timezone="UTC"),
bundle_name=BUNDLE_NAME,
)
session.add(import_error)
session.commit()
Expand All @@ -123,20 +130,25 @@ def test_should_return_200_with_single_dag_read(self, session):
response_data["import_error_id"] = 1
assert response_data == {
"filename": "Lorem_ipsum.py",
"bundle_name": None,
"bundle_name": BUNDLE_NAME,
"import_error_id": 1,
"stack_trace": "Lorem ipsum",
"timestamp": "2020-06-10T12:00:00+00:00",
}

def test_should_return_200_redacted_with_single_dag_read_in_dagfile(self, session):
def test_should_return_200_redacted_with_single_dag_read_in_dagfile(
self, configure_testing_dag_bundle, session
):
with configure_testing_dag_bundle("/tmp"):
DagBundlesManager().sync_bundles_to_db()
for dag_id in TEST_DAG_IDS:
dag_model = DagModel(dag_id=dag_id, fileloc="Lorem_ipsum.py")
dag_model = DagModel(dag_id=dag_id, fileloc="Lorem_ipsum.py", bundle_name=BUNDLE_NAME)
session.add(dag_model)
import_error = ParseImportError(
filename="Lorem_ipsum.py",
stacktrace="Lorem ipsum",
timestamp=timezone.parse(self.timestamp, timezone="UTC"),
bundle_name=BUNDLE_NAME,
)
session.add(import_error)
session.commit()
Expand All @@ -150,7 +162,7 @@ def test_should_return_200_redacted_with_single_dag_read_in_dagfile(self, sessio
response_data["import_error_id"] = 1
assert response_data == {
"filename": "Lorem_ipsum.py",
"bundle_name": None,
"bundle_name": BUNDLE_NAME,
"import_error_id": 1,
"stack_trace": "REDACTED - you do not have read permission on all DAGs in the file",
"timestamp": "2020-06-10T12:00:00+00:00",
Expand All @@ -163,11 +175,11 @@ def test_get_import_errors_single_dag(self, configure_testing_dag_bundle, sessio
DagBundlesManager().sync_bundles_to_db()
for dag_id in TEST_DAG_IDS:
fake_filename = f"/tmp/{dag_id}.py"
dag_model = DagModel(dag_id=dag_id, fileloc=fake_filename, bundle_name="testing")
dag_model = DagModel(dag_id=dag_id, fileloc=fake_filename, bundle_name=BUNDLE_NAME)
session.add(dag_model)
importerror = ParseImportError(
filename=fake_filename,
bundle_name="testing",
bundle_name=BUNDLE_NAME,
stacktrace="Lorem ipsum",
timestamp=timezone.parse(self.timestamp, timezone="UTC"),
)
Expand All @@ -185,7 +197,7 @@ def test_get_import_errors_single_dag(self, configure_testing_dag_bundle, sessio
"import_errors": [
{
"filename": "/tmp/test_dag.py",
"bundle_name": "testing",
"bundle_name": BUNDLE_NAME,
"import_error_id": 1,
"stack_trace": "Lorem ipsum",
"timestamp": "2020-06-10T12:00:00+00:00",
Expand All @@ -204,7 +216,7 @@ def test_get_import_errors_single_dag_in_dagfile(self, configure_testing_dag_bun

importerror = ParseImportError(
filename="/tmp/all_in_one.py",
bundle_name="testing",
bundle_name=BUNDLE_NAME,
stacktrace="Lorem ipsum",
timestamp=timezone.parse(self.timestamp, timezone="UTC"),
)
Expand All @@ -222,7 +234,7 @@ def test_get_import_errors_single_dag_in_dagfile(self, configure_testing_dag_bun
"import_errors": [
{
"filename": "/tmp/all_in_one.py",
"bundle_name": "testing",
"bundle_name": BUNDLE_NAME,
"import_error_id": 1,
"stack_trace": "REDACTED - you do not have read permission on all DAGs in the file",
"timestamp": "2020-06-10T12:00:00+00:00",
Expand Down

0 comments on commit 834f7e1

Please sign in to comment.