28
28
29
29
30
30
@pytest .fixture (scope = "function" )
31
- def dags_directory ():
31
+ def dags_directory () -> str :
32
32
"""Copies contents of dags/ folder to a temporary directory"""
33
33
temp_dir = tempfile .mkdtemp ()
34
34
copytree (DAGS_DIR , f"{ temp_dir } /" , dirs_exist_ok = True )
35
35
yield temp_dir
36
36
37
37
38
38
@pytest .fixture (scope = "function" )
39
- def empty_directory ():
39
+ def empty_directory () -> str :
40
40
temp_dir = tempfile .mkdtemp ()
41
41
yield temp_dir
42
42
43
43
44
44
# test bucket used in lieu of an actual Composer environment bucket
45
45
@pytest .fixture (scope = "module" )
46
- def test_bucket ():
46
+ def test_bucket () -> str :
47
47
"""Yields a bucket that is deleted after the test completes."""
48
48
storage_client = storage .Client ()
49
49
@@ -58,32 +58,32 @@ def test_bucket():
58
58
bucket .delete (force = True )
59
59
60
60
61
- def test_create_dags_list_invalid_directory ():
61
+ def test_create_dags_list_invalid_directory () -> None :
62
62
with pytest .raises (FileNotFoundError ):
63
63
(temp_dir , dags ) = add_dags_to_composer ._create_dags_list ("this-directory-does-not-exist/" ) # noqa: E117
64
64
65
65
66
- def test_create_dags_list_empty_directory (empty_directory ) :
66
+ def test_create_dags_list_empty_directory (empty_directory : str ) -> None :
67
67
(temp_dir , dags ) = add_dags_to_composer ._create_dags_list (empty_directory ) # noqa: E117
68
68
assert len (dags ) == 0
69
69
assert len (os .listdir (temp_dir )) == 0
70
70
71
71
72
- def test_create_dags_list (dags_directory ) :
72
+ def test_create_dags_list (dags_directory : str ) -> None :
73
73
(temp_dir , dags ) = add_dags_to_composer ._create_dags_list (dags_directory )
74
74
assert len (dags ) == 2
75
75
assert f"{ temp_dir } /__init__.py" not in dags
76
76
assert f"{ temp_dir } /example_dag.py" in dags
77
77
assert f"{ temp_dir } /example2_dag.py" in dags
78
78
79
79
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 :
81
81
add_dags_to_composer .upload_dags_to_composer (empty_directory , test_bucket )
82
82
out , _ = capsys .readouterr ()
83
83
assert "No DAGs to upload." in out
84
84
85
85
86
- def test_upload_dags_to_composer (test_bucket , capsys ) :
86
+ def test_upload_dags_to_composer (test_bucket : str , capsys : pytest . CaptureFixture ) -> None :
87
87
add_dags_to_composer .upload_dags_to_composer (DAGS_DIR , test_bucket )
88
88
out , _ = capsys .readouterr ()
89
89
assert "uploaded" in out
0 commit comments