Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: General Bugfixes for WP4 #49

Merged
merged 5 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
GeraldIr marked this conversation as resolved.
Show resolved Hide resolved
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),
GeraldIr marked this conversation as resolved.
Show resolved Hide resolved
headers={
"Content-Type": "application/json",
"Authorization": f"{bearer_token}",
Expand Down
Loading
Loading