Skip to content

Commit

Permalink
changed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vighnesh-wednesday committed Dec 18, 2023
1 parent 9adf7fb commit 8ed8c48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def get_dataframes(databricks: bool, spark, directory_path: str):

if databricks:
csv_files = [
file for file in os.listdir(directory_path) if file.endswith(".csv")
file
for file in os.listdir("/dbfs" + directory_path)
if file.endswith(".csv")
]
else:
cmd = f"aws s3 ls {directory_path}"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestSetKeysGetSpark(unittest.TestCase):
@patch("app.environment.cg.init_glue")
@patch("app.connect_glue.init_glue")
@patch("app.environment.cd.create_mount")
@patch("app.environment.dotenv.load_dotenv")
def test_databricks_environment(
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_databricks_environment(
mock_init_glue.assert_not_called()
mock_load_dotenv.assert_not_called()

@patch("app.environment.cg.init_glue")
@patch("app.connect_glue.init_glue")
@patch("app.environment.cd.create_mount")
@patch("app.environment.dotenv.load_dotenv")
def test_glue_local_environment(
Expand All @@ -66,7 +66,7 @@ def test_glue_local_environment(
mock_init_glue.assert_called_once()
mock_load_dotenv.assert_called_once()

@patch("app.environment.cg.init_glue")
@patch("app.connect_glue.init_glue")
@patch("app.environment.cd.create_mount")
@patch("app.environment.dotenv.load_dotenv")
def test_glue_online_environment(
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_databricks_dataframes(self, mock_run, mock_listdir, mock_create_frame):

# Assertions
self.assertEqual(len(result_df_list), 2)
mock_listdir.assert_called_with(directory_path)
mock_listdir.assert_called_with("/dbfs" + directory_path)
mock_create_frame.assert_any_call(spark, "/mnt/rawdata/file1.csv")
mock_create_frame.assert_any_call(spark, "/mnt/rawdata/file2.csv")
mock_run.assert_not_called()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_environment_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestSetKeysGetSpark(unittest.TestCase):
@patch("app.environment.cg.init_glue")
@patch("app.connect_glue.init_glue")
@patch("app.environment.cd.create_mount")
@patch("app.environment.dotenv.load_dotenv")
def test_databricks_environment_failure(
Expand All @@ -35,7 +35,7 @@ def test_databricks_environment_failure(
mock_init_glue.assert_not_called()
mock_load_dotenv.assert_not_called()

@patch("app.environment.cg.init_glue")
@patch("app.connect_glue.init_glue")
@patch("app.environment.cd.create_mount")
@patch("app.environment.dotenv.load_dotenv")
def test_glue_local_environment_failure(
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_databricks_dataframes_failure(self, mock_create_frame, mock_listdir):

# Assert
self.assertEqual(str(context.exception), "Error listing directory")
mock_listdir.assert_called_with(directory_path)
mock_listdir.assert_called_with("/dbfs" + directory_path)
mock_create_frame.assert_not_called()

@patch("app.environment.sw.create_frame")
Expand Down

0 comments on commit 8ed8c48

Please sign in to comment.