Skip to content

Commit

Permalink
Merge pull request #49 from eodcgmbh/general-api-compliance-fixes
Browse files Browse the repository at this point in the history
Fixes: General Bugfixes for WP4
  • Loading branch information
soxofaan authored Mar 8, 2024
2 parents 454e860 + ad489d1 commit 2019ce4
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 695 deletions.
19 changes: 10 additions & 9 deletions src/openeo_test_suite/lib/compliance_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _guess_root():

def get_examples_path():
return (
_guess_root().parents[2]
_guess_root().parents[1]
/ "src"
/ "openeo_test_suite"
/ "tests"
Expand All @@ -287,14 +287,14 @@ def get_spec_path():
return _guess_root() / "openapi.yaml"


def load_payloads_from_directory(directory_path: str) -> Iterator[str]:
def load_payloads_from_directory(directory_path: str) -> Iterator[dict]:
for filename in pathlib.Path(directory_path).glob("*.json"):
file_path = os.path.join(directory_path, filename)
with open(file_path, "r") as file:
try:
# Load the JSON data from the file
data = json.load(file)
yield json.dumps(data)
yield data
except json.JSONDecodeError:
_log.error(f"Error decoding JSON in file: {filename}")
except Exception as e:
Expand All @@ -309,7 +309,7 @@ def set_uuid_in_job(json_data):
# Set the 'id' field to the generated UUID
json_data["process"]["id"] = new_id
# Return the modified JSON object
return new_id, json.dumps(json_data)
return new_id, json_data


def delete_id_resource(
Expand All @@ -336,18 +336,19 @@ def put_process_graphs(base_url: str, bearer_token: str): # TODO id and so fort

try:
for payload in payloads:
id = str(uuid.uuid4().hex)
id, payload = set_uuid_in_udp(payload)
created_udp_ids.append(id)
requests.put(
f"{base_url}/process_graphs/{id}",
response = requests.put(
f"{base_url}process_graphs/{id}",
data=payload,
headers={
"Content-Type": "application/json",
"Authorization": f"{bearer_token}",
},
)
print(response)
except Exception as e:
print(f"Failed to create process graph: {e}")
_log.error(f"Failed to create process graph: {e}")
return created_udp_ids


Expand Down Expand Up @@ -380,7 +381,7 @@ def post_jobs(base_url: str, bearer_token: str):

response = requests.post(
full_endpoint_url,
data=payload,
data=json.dumps(payload),
headers={
"Content-Type": "application/json",
"Authorization": f"{bearer_token}",
Expand Down
Loading

0 comments on commit 2019ce4

Please sign in to comment.