17
17
BUCKET = "bucket"
18
18
FILEPATH = "fake/path/" + FILENAME
19
19
SAVE_NAME = "fakeSaveName"
20
- EXISTING_FILE_URI = "gs://bucket/existing_file.json"
20
+ EXISTING_FILE_URI = "gs://bucket/" + SAVE_NAME
21
21
GCS_FILE_URI = functions .GCS_URI .format (bucket = BUCKET , filename = FILENAME )
22
22
23
23
###############################################################################
@@ -56,19 +56,76 @@ def test_get_file_uri(
56
56
57
57
58
58
@pytest .mark .parametrize (
59
- "bucket, filepath, save_name, remove_local, existing_file_uri, expected" ,
59
+ "bucket, filepath, save_name, remove_local, overwrite, existing_file_uri, expected" ,
60
60
[
61
- (BUCKET , FILEPATH , SAVE_NAME , True , EXISTING_FILE_URI , EXISTING_FILE_URI ),
62
- (BUCKET , FILEPATH , SAVE_NAME , False , EXISTING_FILE_URI , EXISTING_FILE_URI ),
63
- (BUCKET , FILEPATH , None , False , None , GCS_FILE_URI ),
64
- (BUCKET , FILEPATH , None , True , None , GCS_FILE_URI ),
61
+ (
62
+ BUCKET ,
63
+ FILEPATH ,
64
+ SAVE_NAME ,
65
+ True ,
66
+ True ,
67
+ EXISTING_FILE_URI ,
68
+ EXISTING_FILE_URI ,
69
+ ),
70
+ (
71
+ BUCKET ,
72
+ FILEPATH ,
73
+ SAVE_NAME ,
74
+ True ,
75
+ True ,
76
+ None ,
77
+ EXISTING_FILE_URI ,
78
+ ),
79
+ (
80
+ BUCKET ,
81
+ FILEPATH ,
82
+ SAVE_NAME ,
83
+ True ,
84
+ False ,
85
+ EXISTING_FILE_URI ,
86
+ EXISTING_FILE_URI ,
87
+ ),
88
+ (
89
+ BUCKET ,
90
+ FILEPATH ,
91
+ SAVE_NAME ,
92
+ False ,
93
+ True ,
94
+ EXISTING_FILE_URI ,
95
+ EXISTING_FILE_URI ,
96
+ ),
97
+ (
98
+ BUCKET ,
99
+ FILEPATH ,
100
+ SAVE_NAME ,
101
+ False ,
102
+ True ,
103
+ None ,
104
+ EXISTING_FILE_URI ,
105
+ ),
106
+ (
107
+ BUCKET ,
108
+ FILEPATH ,
109
+ SAVE_NAME ,
110
+ False ,
111
+ False ,
112
+ EXISTING_FILE_URI ,
113
+ EXISTING_FILE_URI ,
114
+ ),
115
+ (BUCKET , FILEPATH , None , False , True , GCS_FILE_URI , GCS_FILE_URI ),
116
+ (BUCKET , FILEPATH , None , False , True , None , GCS_FILE_URI ),
117
+ (BUCKET , FILEPATH , None , False , False , None , GCS_FILE_URI ),
118
+ (BUCKET , FILEPATH , None , True , True , GCS_FILE_URI , GCS_FILE_URI ),
119
+ (BUCKET , FILEPATH , None , True , True , None , GCS_FILE_URI ),
120
+ (BUCKET , FILEPATH , None , True , False , None , GCS_FILE_URI ),
65
121
],
66
122
)
67
123
def test_upload_file (
68
124
bucket : str ,
69
125
filepath : str ,
70
126
save_name : Optional [str ],
71
127
remove_local : bool ,
128
+ overwrite : bool ,
72
129
existing_file_uri : str ,
73
130
expected : str ,
74
131
) -> None :
@@ -82,7 +139,12 @@ def test_upload_file(
82
139
mock_path .return_value .name = FILENAME
83
140
84
141
assert expected == functions .upload_file (
85
- "path/to/creds" , bucket , filepath , save_name , remove_local
142
+ "path/to/creds" ,
143
+ bucket ,
144
+ filepath ,
145
+ save_name ,
146
+ remove_local ,
147
+ overwrite ,
86
148
)
87
149
88
150
0 commit comments