Skip to content

Commit bbaea5f

Browse files
committed
add type annotations to test
1 parent 9a00dc0 commit bbaea5f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

composer/cicd_sample/utils/add_dags_to_composer_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@
2828

2929

3030
@pytest.fixture(scope="function")
31-
def dags_directory():
31+
def dags_directory() -> str:
3232
"""Copies contents of dags/ folder to a temporary directory"""
3333
temp_dir = tempfile.mkdtemp()
3434
copytree(DAGS_DIR, f"{temp_dir}/", dirs_exist_ok=True)
3535
yield temp_dir
3636

3737

3838
@pytest.fixture(scope="function")
39-
def empty_directory():
39+
def empty_directory() -> str:
4040
temp_dir = tempfile.mkdtemp()
4141
yield temp_dir
4242

4343

4444
# test bucket used in lieu of an actual Composer environment bucket
4545
@pytest.fixture(scope="module")
46-
def test_bucket():
46+
def test_bucket() -> str:
4747
"""Yields a bucket that is deleted after the test completes."""
4848
storage_client = storage.Client()
4949

@@ -58,32 +58,32 @@ def test_bucket():
5858
bucket.delete(force=True)
5959

6060

61-
def test_create_dags_list_invalid_directory():
61+
def test_create_dags_list_invalid_directory() -> None:
6262
with pytest.raises(FileNotFoundError):
6363
(temp_dir, dags) = add_dags_to_composer._create_dags_list("this-directory-does-not-exist/") # noqa: E117
6464

6565

66-
def test_create_dags_list_empty_directory(empty_directory):
66+
def test_create_dags_list_empty_directory(empty_directory: str) -> None:
6767
(temp_dir, dags) = add_dags_to_composer._create_dags_list(empty_directory) # noqa: E117
6868
assert len(dags) == 0
6969
assert len(os.listdir(temp_dir)) == 0
7070

7171

72-
def test_create_dags_list(dags_directory):
72+
def test_create_dags_list(dags_directory: str) -> None:
7373
(temp_dir, dags) = add_dags_to_composer._create_dags_list(dags_directory)
7474
assert len(dags) == 2
7575
assert f"{temp_dir}/__init__.py" not in dags
7676
assert f"{temp_dir}/example_dag.py" in dags
7777
assert f"{temp_dir}/example2_dag.py" in dags
7878

7979

80-
def test_upload_dags_to_composer_no_files(capsys, empty_directory, test_bucket):
80+
def test_upload_dags_to_composer_no_files(capsys: pytest.CaptureFixture, empty_directory: str, test_bucket: str) -> None:
8181
add_dags_to_composer.upload_dags_to_composer(empty_directory, test_bucket)
8282
out, _ = capsys.readouterr()
8383
assert "No DAGs to upload." in out
8484

8585

86-
def test_upload_dags_to_composer(test_bucket, capsys):
86+
def test_upload_dags_to_composer(test_bucket: str, capsys: pytest.CaptureFixture) -> None:
8787
add_dags_to_composer.upload_dags_to_composer(DAGS_DIR, test_bucket)
8888
out, _ = capsys.readouterr()
8989
assert "uploaded" in out

0 commit comments

Comments
 (0)