99import pytest
1010from cmem .cmempy .workspace .projects .project import delete_project , make_new_project
1111from cmem .cmempy .workspace .projects .resources .resource import create_resource , get_resource
12- from requests . exceptions import HTTPError
12+ from requests import HTTPError
1313
1414from cmem_plugin_splitfile .plugin_splitfile import SplitFilePlugin
1515from tests .utils import TestExecutionContext , needs_cmem
@@ -57,12 +57,12 @@ def test_filesystem_size() -> None:
5757 size_unit = "KB" ,
5858 projects_path = __path__ [0 ],
5959 use_directory = True ,
60- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
60+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
6161
6262 for n in range (3 ):
6363 assert cmp (
64- Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
65- Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" ,
64+ Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
65+ Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" ,
6666 )
6767
6868 if not (Path (__path__ [0 ]) / PROJECT_ID / "resources" / TEST_FILENAME ).is_file ():
@@ -80,12 +80,12 @@ def test_filesystem_size_header() -> None:
8080 include_header = True ,
8181 projects_path = __path__ [0 ],
8282 use_directory = True ,
83- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
83+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
8484
8585 for n in range (3 ):
8686 assert cmp (
87- Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
88- Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_header_00000000{ n + 1 } .nt" ,
87+ Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
88+ Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_header_00000000{ n + 1 } .nt" ,
8989 )
9090
9191 if not (Path (__path__ [0 ]) / PROJECT_ID / "resources" / TEST_FILENAME ).is_file ():
@@ -101,13 +101,13 @@ def test_api_size() -> None:
101101 chunk_size = 6 ,
102102 size_unit = "KB" ,
103103 projects_path = __path__ [0 ],
104- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
104+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
105105
106106 for n in range (3 ):
107- f = get_resource (project_name = PROJECT_ID , resource_name = f"{ UUID4 } _00000000{ n + 1 } .nt" )
107+ f = get_resource (project_name = PROJECT_ID , resource_name = f"{ UUID4 } _00000000{ n + 1 } .nt" )
108108 assert (
109109 f
110- == (Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" )
110+ == (Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" )
111111 .open ("rb" )
112112 .read ()
113113 )
@@ -126,12 +126,12 @@ def test_filesystem_size_delete() -> None:
126126 projects_path = __path__ [0 ],
127127 use_directory = True ,
128128 delete_file = True ,
129- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
129+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
130130
131131 for n in range (3 ):
132132 assert cmp (
133- Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
134- Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" ,
133+ Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
134+ Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" ,
135135 )
136136
137137 if (Path (__path__ [0 ]) / PROJECT_ID / "resources" / TEST_FILENAME ).is_file ():
@@ -148,24 +148,19 @@ def test_api_size_delete() -> None:
148148 size_unit = "KB" ,
149149 projects_path = __path__ [0 ],
150150 delete_file = True ,
151- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
151+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
152152
153153 for n in range (3 ):
154- f = get_resource (project_name = PROJECT_ID , resource_name = f"{ UUID4 } _00000000{ n + 1 } .nt" )
154+ f = get_resource (project_name = PROJECT_ID , resource_name = f"{ UUID4 } _00000000{ n + 1 } .nt" )
155155 assert (
156156 f
157- == (Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" )
157+ == (Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _size_00000000{ n + 1 } .nt" )
158158 .open ("rb" )
159159 .read ()
160160 )
161161
162- try :
162+ with pytest . raises ( HTTPError , match = "404 Client Error: Not Found for url:" ) :
163163 get_resource (project_name = PROJECT_ID , resource_name = TEST_FILENAME )
164- except Exception as exc :
165- if type (exc ) is HTTPError and exc .status_code == 404 : # noqa: PLR2004
166- pass
167- else :
168- raise
169164
170165
171166@needs_cmem
@@ -178,12 +173,12 @@ def test_filesystem_lines() -> None:
178173 size_unit = "Lines" ,
179174 projects_path = __path__ [0 ],
180175 use_directory = True ,
181- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
176+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
182177
183178 for n in range (3 ):
184179 assert cmp (
185- Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
186- Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _lines_00000000{ n + 1 } .nt" ,
180+ Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
181+ Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _lines_00000000{ n + 1 } .nt" ,
187182 )
188183
189184
@@ -198,10 +193,10 @@ def test_filesystem_lines_header() -> None:
198193 include_header = True ,
199194 projects_path = __path__ [0 ],
200195 use_directory = True ,
201- ).execute (None , context = TestExecutionContext (PROJECT_ID ))
196+ ).execute (inputs = [] , context = TestExecutionContext (PROJECT_ID ))
202197
203198 for n in range (3 ):
204199 assert cmp (
205- Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
206- Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _lines_header_00000000{ n + 1 } .nt" ,
200+ Path (__path__ [0 ]) / PROJECT_ID / "resources" / f"{ UUID4 } _00000000{ n + 1 } .nt" ,
201+ Path (__path__ [0 ]) / "test_files" / f"{ UUID4 } _lines_header_00000000{ n + 1 } .nt" ,
207202 )
0 commit comments