Skip to content

Commit

Permalink
Apply black to whole tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 1, 2024
1 parent 51986f4 commit 9aedf93
Show file tree
Hide file tree
Showing 15 changed files with 1,239 additions and 1,235 deletions.
2 changes: 0 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def pytest_configure(config):
os.environ["OPENEO_BACKEND_CONFIG"] = str(Path(__file__).parent / "backend_config.py")




_DEFAULT_PROCESSES = [
"load_collection",
"load_result",
Expand Down
141 changes: 60 additions & 81 deletions tests/metadata/test_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def test_merge_processes_minimal(self, merger, reporter):
"parameters": [],
"returns": {"schema": {}},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': [],
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
}
assert reporter.logs == []
Expand All @@ -55,10 +55,10 @@ def test_merge_process_minimal(self, merger, reporter):
"parameters": [],
"returns": {"schema": {}},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == []

Expand All @@ -72,19 +72,12 @@ def test_merge_process_returns(self, merger, reporter):
"type": "array",
"items": {"description": "All data types are allowed."},
},
"description": "some description"
}
"description": "some description",
},
},
"b2": {
"id": "add",
"returns": {
"schema": {
"type": "array",
"items": {
"description": "Any data type is allowed."
}
}
}
"returns": {"schema": {"type": "array", "items": {"description": "Any data type is allowed."}}},
},
}
)
Expand All @@ -93,18 +86,18 @@ def test_merge_process_returns(self, merger, reporter):
"id": "add",
"description": "add",
"parameters": [],
'returns': {
"returns": {
"description": "some description",
"schema": {
"type": "array",
"items": {"description": "All data types are allowed."},
},
},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == []

Expand All @@ -122,10 +115,10 @@ def test_merge_process_returns_difference(self, merger, reporter):
"parameters": [],
"returns": {"schema": {"type": "number"}},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == [
{
Expand Down Expand Up @@ -175,10 +168,10 @@ def test_merge_process_exceptions(self, merger, reporter):
"OverflowError": {"message": "Jeez"},
},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == []

Expand All @@ -203,10 +196,10 @@ def test_merge_process_exceptions_invalid(self, merger, reporter):
"returns": {"schema": {}},
"exceptions": {"MathError": {"message": "Nope"}},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == [
{
Expand All @@ -232,10 +225,10 @@ def test_merge_process_categories(self, merger, reporter):
"returns": {"schema": {}},
"categories": ["Math", "Maths"],
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == []

Expand All @@ -254,10 +247,10 @@ def test_merge_process_categories_invalid(self, merger, reporter):
"returns": {"schema": {}},
"categories": ["Math"],
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == [
{
Expand Down Expand Up @@ -308,10 +301,10 @@ def test_merge_process_parameters_basic(self, merger, reporter):
],
"returns": {"schema": {}},
"federation:backends": ["b1", "b2"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': []
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == []

Expand All @@ -336,9 +329,7 @@ def test_merge_process_parameters_invalid(self, merger, reporter):
"description": "cos",
"federation:backends": ["b1", "b2"],
"id": "cos",
"parameters": [
{"name": "x", "schema": {"type": "number"}, "description": "x value"}
],
"parameters": [{"name": "x", "schema": {"type": "number"}, "description": "x value"}],
"returns": {"schema": {}},
"deprecated": False,
"experimental": False,
Expand Down Expand Up @@ -382,9 +373,7 @@ def test_merge_process_parameters_missing_required(self, merger, reporter):
"description": "cos",
"federation:backends": ["b1", "b2"],
"id": "cos",
"parameters": [
{"name": "x", "schema": {"type": "number"}, "description": "x value"}
],
"parameters": [{"name": "x", "schema": {"type": "number"}, "description": "x value"}],
"returns": {"schema": {}},
"deprecated": False,
"experimental": False,
Expand Down Expand Up @@ -441,14 +430,12 @@ def test_merge_process_parameters_invalid_listing(self, merger, reporter):
"description": "cos",
"federation:backends": ["b1", "b2"],
"id": "cos",
"parameters": [
{"name": "x", "schema": {"type": "number"}, "description": "x value"}
],
"parameters": [{"name": "x", "schema": {"type": "number"}, "description": "x value"}],
"returns": {"schema": {}},
'deprecated': False,
'experimental': False,
'examples': [],
'links': [],
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == [
{
Expand Down Expand Up @@ -509,10 +496,10 @@ def test_merge_process_parameters_differences(self, merger, reporter):
],
"returns": {"schema": {}},
"federation:backends": ["b1", "b2", "b3"],
'deprecated': False,
'experimental': False,
'examples': [],
'links': [],
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}
assert reporter.logs == [
{
Expand Down Expand Up @@ -540,7 +527,7 @@ def test_merge_process_parameters_differences(self, merger, reporter):
'+ "type": "array"\n',
" }\n",
],
}
},
]

def test_merge_process_parameters_differences_precedence(self, merger, reporter):
Expand Down Expand Up @@ -632,9 +619,7 @@ def test_merge_process_parameters_recursive(self, merger, reporter):
"schema": {
"type": "object",
"subtype": "process-graph",
"parameters": [
{"name": "x", "schema": {}, "description": "the x"}
],
"parameters": [{"name": "x", "schema": {}, "description": "the x"}],
"returns": {"schema": {}},
},
},
Expand Down Expand Up @@ -679,9 +664,7 @@ def test_merge_process_parameters_recursive(self, merger, reporter):
"schema": {
"type": "object",
"subtype": "process-graph",
"parameters": [
{"name": "x", "description": "the x", "schema": {}}
],
"parameters": [{"name": "x", "description": "the x", "schema": {}}],
"returns": {"schema": {}},
},
}
Expand Down Expand Up @@ -714,9 +697,7 @@ def test_merge_process_parameters_recursive2(self, merger, reporter):
"description": "what to count",
"schema": [
{
"parameters": [
{"name": "x", "schema": {}, "description": "X."}
],
"parameters": [{"name": "x", "schema": {}, "description": "X."}],
"returns": {"schema": {"type": "boolean"}},
"subtype": "process-graph",
"type": "object",
Expand Down Expand Up @@ -789,9 +770,7 @@ def test_merge_process_parameters_recursive2(self, merger, reporter):
{
"type": "object",
"subtype": "process-graph",
"parameters": [
{"name": "x", "description": "X.", "schema": {}}
],
"parameters": [{"name": "x", "description": "X.", "schema": {}}],
"returns": {"schema": {"type": "boolean"}},
},
{"const": True, "type": "boolean"},
Expand All @@ -800,10 +779,10 @@ def test_merge_process_parameters_recursive2(self, merger, reporter):
],
"returns": {"schema": {"type": "number"}},
"summary": "Count the number of elements",
'deprecated': False,
'experimental': False,
'examples': [],
'links': [],
"deprecated": False,
"experimental": False,
"examples": [],
"links": [],
}

assert reporter.logs == []
Expand Down
31 changes: 12 additions & 19 deletions tests/partitionedjobs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
TEST_USER = "tstsr"
TEST_USER_BEARER_TOKEN = "basic//" + HttpAuthHandler.build_basic_access_token(user_id=TEST_USER)

PG12 = {
"add": {"process_id": "add", "arguments": {"X": 1, "y": 2}, "result": True}
}
PG23 = {
"add": {"process_id": "add", "arguments": {"X": 2, "y": 3}, "result": True}
}
PG35 = {
"add": {"process_id": "add", "arguments": {"X": 3, "y": 5}, "result": True}
}
PG12 = {"add": {"process_id": "add", "arguments": {"X": 1, "y": 2}, "result": True}}
PG23 = {"add": {"process_id": "add", "arguments": {"X": 2, "y": 3}, "result": True}}
PG35 = {"add": {"process_id": "add", "arguments": {"X": 3, "y": 5}, "result": True}}
P12 = {"process_graph": PG12}
P23 = {"process_graph": PG23}
P35 = {"process_graph": PG35}
Expand Down Expand Up @@ -110,22 +104,21 @@ def get_job_status(self, user_id: str, job_id: str):
return self.get_job_data(user_id, job_id).history[-1]

def setup_assets(self, job_id: str, assets: List[str] = None):
"""Mock `GET /jobs/{}/results` response with fake assets """
"""Mock `GET /jobs/{}/results` response with fake assets"""
if assets is None:
assets = ["preview.png", "result.tif"]
results = {"assets": {
a: {"href": self.backend_url + f"/jobs/{job_id}/results/{a}"}
for a in assets
}}
results = {"assets": {a: {"href": self.backend_url + f"/jobs/{job_id}/results/{a}"} for a in assets}}
self.requests_mock.get(self.backend_url + f"/jobs/{job_id}/results", json=results)

def _handle_get_jobs(self, request: requests.Request, context):
user_id = self.get_user_id(request)
return {"jobs": [
{"id": job_id, "created": timestamp_to_rfc3339(job_data.created), "status": job_data.history[-1]}
for (u, job_id), job_data in self.jobs.items()
if u == user_id
]}
return {
"jobs": [
{"id": job_id, "created": timestamp_to_rfc3339(job_data.created), "status": job_data.history[-1]}
for (u, job_id), job_data in self.jobs.items()
if u == user_id
]
}

def _handle_post_jobs(self, request: requests.Request, context):
"""`POST /jobs` handler (create job)"""
Expand Down
Loading

0 comments on commit 9aedf93

Please sign in to comment.