@@ -26,11 +26,13 @@ def write_csv_path(test_dir: str) -> str:
2626
2727
2828# Test is_file()
29+ @pytest .mark .utilities
2930def test_is_file_exists (test_dir : str ) -> None :
3031 test_file = os .path .join (test_dir , "test.csv" )
3132 assert fdp_utils .is_file (test_file )
3233
3334
35+ @pytest .mark .utilities
3436@pytest .mark .parametrize (
3537 "file_path" ,
3638 [
@@ -43,12 +45,14 @@ def test_is_file_not_exists(file_path: str) -> None:
4345 assert not fdp_utils .is_file (file_path )
4446
4547
48+ @pytest .mark .utilities
4649@pytest .mark .parametrize ("file_path" , ["read_csv_path" , "write_csv_path" ])
4750def test_is_yaml (file_path : str , request : FixtureRequest ) -> None :
4851 file_path = request .getfixturevalue (file_path )
4952 assert fdp_utils .is_yaml (file_path )
5053
5154
55+ @pytest .mark .utilities
5256@pytest .mark .parametrize (
5357 "file_path" ,
5458 [
@@ -62,12 +66,14 @@ def test_is_yaml_not(file_path: str) -> None:
6266 assert not fdp_utils .is_yaml (file_path )
6367
6468
69+ @pytest .mark .utilities
6570@pytest .mark .parametrize ("file_path" , ["read_csv_path" , "write_csv_path" ])
6671def test_is_valid_yaml (file_path : str , request : FixtureRequest ) -> None :
6772 file_path = request .getfixturevalue (file_path )
6873 assert fdp_utils .is_yaml (file_path )
6974
7075
76+ @pytest .mark .utilities
7177@pytest .mark .parametrize (
7278 "file_path" ,
7379 [
@@ -81,6 +87,7 @@ def test_is_valid_yaml_not(file_path: str) -> None:
8187 assert not fdp_utils .is_valid_yaml (file_path )
8288
8389
90+ @pytest .mark .utilities
8491def test_read_token (test_dir : str ) -> None :
8592 token = os .path .join (test_dir , "test_token" )
8693 assert (
@@ -89,6 +96,7 @@ def test_read_token(test_dir: str) -> None:
8996 )
9097
9198
99+ @pytest .mark .utilities
92100def test_get_token (test_dir : str ) -> None :
93101 token = os .path .join (test_dir , "test_token" )
94102 assert (
@@ -97,6 +105,7 @@ def test_get_token(test_dir: str) -> None:
97105 )
98106
99107
108+ @pytest .mark .utilities
100109def test_read_token_get_token (test_dir : str ) -> None :
101110 token = os .path .join (test_dir , "test_token" )
102111 assert fdp_utils .read_token (token ) == fdp_utils .get_token (token )
@@ -109,6 +118,7 @@ def token() -> str:
109118 )
110119
111120
121+ @pytest .mark .utilities
112122def test_get_file_hash (test_dir : str ) -> None :
113123 file_path = os .path .join (test_dir , "test.csv" )
114124 if platform .system () == "Windows" :
@@ -123,32 +133,47 @@ def test_get_file_hash(test_dir: str) -> None:
123133 )
124134
125135
136+ @pytest .mark .utilities
126137def test_random_hash_is_string () -> None :
127138 assert type (fdp_utils .random_hash ()) == str
128139
129140
141+ @pytest .mark .utilities
130142def test_random_hash_length () -> None :
131143 assert len (fdp_utils .random_hash ()) == 40
132144
133145
146+ @pytest .mark .utilities
134147def test_extract_id () -> None :
135148 assert fdp_utils .extract_id ("http://localhost:8000/api/object/85" ) == "85"
136149
137150
151+ @pytest .mark .utilities
152+ def test_extract_id_should_fail () -> None :
153+ with pytest .raises (IndexError ):
154+ fdp_utils .extract_id ("" )
155+
156+
157+ @pytest .mark .utilities
138158def test_get_headers () -> None :
139159 assert type (fdp_utils .get_headers ()) == dict
160+ headers = {"Accept" : "application/json; version=" + "1.0.0" }
161+ assert headers == fdp_utils .get_headers ()
140162
141163
164+ @pytest .mark .utilities
142165def test_get_headers_with_token (token : str ) -> None :
143166 headers = fdp_utils .get_headers (token = token )
144167 assert headers ["Authorization" ] == "token " + token
145168
146169
170+ @pytest .mark .utilities
147171def test_get_headers_post () -> None :
148172 headers = fdp_utils .get_headers (request_type = "post" )
149173 assert headers ["Content-Type" ] == "application/json"
150174
151175
176+ @pytest .mark .utilities
152177def test_get_headers_api_version () -> None :
153178 headers = fdp_utils .get_headers (api_version = "0.0.1" )
154179 assert headers ["Accept" ] == "application/json; version=0.0.1"
@@ -232,6 +257,32 @@ def test_get_entry(url: str, token: str, storage_root_test: dict) -> None:
232257 assert entry [0 ] == storage_root_test
233258
234259
260+ @pytest .mark .utilities
261+ def test_get_entry_author (url : str , token : str ) -> None :
262+
263+ results = fdp_utils .get_entry (
264+ url = url ,
265+ query = {"user" : 2 },
266+ token = token ,
267+ endpoint = "user_author" ,
268+ )
269+ with pytest .raises (IndexError ):
270+ _ = results [0 ]
271+
272+
273+ @pytest .mark .utilities
274+ def test_get_entry_users (url : str , token : str ) -> None :
275+
276+ results = fdp_utils .get_entry (
277+ url = url ,
278+ query = {"username" : "admin1" },
279+ token = token ,
280+ endpoint = "users" ,
281+ )
282+ with pytest .raises (IndexError ):
283+ _ = results [0 ]
284+
285+
235286@pytest .mark .utilities
236287def test_get_entity (url : str , storage_root_test : dict ) -> None :
237288 entity = fdp_utils .get_entity (
0 commit comments