-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable tests and create test workflow
- Loading branch information
Showing
7 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' # specify the Python version you need | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install pytest | ||
- name: Run tests | ||
run: | | ||
pytest tests/ | ||
- name: Upload pytest results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pytest-results | ||
path: tests/results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import requests | ||
|
||
|
||
class BaseAPI: | ||
def __init__(self, base_url): | ||
self.base_url = base_url | ||
|
||
def _call_api(self, endpoint, method='GET', data=None): | ||
url = self.base_url + endpoint | ||
headers = { | ||
'Content-Type': 'application/json' | ||
} | ||
|
||
try: | ||
if method.upper() == 'POST': | ||
response = requests.post(url, headers=headers, data=json.dumps(data)) | ||
elif method.upper() == 'GET': | ||
response = requests.get(url, headers=headers, params=data) | ||
elif method.upper() == 'PUT': | ||
response = requests.put(url, headers=headers, data=json.dumps(data)) | ||
elif method.upper() == 'DELETE': | ||
response = requests.delete(url, headers=headers, data=json.dumps(data)) | ||
else: | ||
raise ValueError(f"Unsupported HTTP method: {method}") | ||
|
||
response.raise_for_status() | ||
return response.json() | ||
except requests.exceptions.HTTPError as http_err: | ||
print(f"HTTP error occurred: {http_err}") | ||
except Exception as err: | ||
print(f"An error occurred: {err}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import requests | ||
|
||
from pygeoweaver.api_call.pgw_base_api_caller import BaseAPI | ||
|
||
class GeoweaverProcessAPI(BaseAPI): | ||
|
||
def edit_process(self, process_data): | ||
return self._call_api('/edit/process', method='POST', data=process_data) | ||
|
||
def add_process(self, process_data): | ||
return self._call_api('/add/process', method='POST', data=process_data) | ||
|
||
def get_process(self, process_id): | ||
return self._call_api(f'/get/process/{process_id}', method='GET') | ||
|
||
def delete_process(self, process_id): | ||
return self._call_api(f'/delete/process/{process_id}', method='DELETE') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
from pygeoweaver.api_call.pgw_base_api_caller import BaseAPI | ||
|
||
|
||
class GeoweaverWorkflowAPI(BaseAPI): | ||
def add_workflow(self, workflow_data): | ||
return self._call_api('/add/workflow', method='POST', data=workflow_data) | ||
|
||
def edit_workflow(self, workflow_data): | ||
return self._call_api('/edit/workflow', method='POST', data=workflow_data) | ||
|
||
def get_workflow(self, workflow_id): | ||
return self._call_api(f'/get/workflow/{workflow_id}', method='GET') | ||
|
||
def delete_workflow(self, workflow_id): | ||
return self._call_api(f'/delete/workflow/{workflow_id}', method='DELETE') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ dependencies = [ | |
"pandas", | ||
"halo", | ||
"tabulate", | ||
"psutil", | ||
] | ||
|
||
[project.urls] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters