-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#97] Rename and update backend tests for GovTool rebranding
This commit encompasses a significant update to the backend testing suite, aligning it with the GovTool rebranding as part of ticket #111. The changes include renaming test directories, files, and updating references within the test cases to reflect the new project codename. Technical Details: - Renamed the backend testing directory from `tests/vva-be` to `tests/govtool-backend`. - Updated `.github/workflows/test_backend.yml` to reference the new test directory and updated project URLs. - Renamed several files within the test directory, including `.env.example`, `.gitignore`, `README.md`, `config.py`, and various test case files. - Modified test case files to replace 'vva' references with 'govtool', ensuring the tests are correctly aligned with the updated backend application name.
- Loading branch information
Showing
22 changed files
with
115 additions
and
37 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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
from models.TestData import AdaHolder, Delegation | ||
|
||
def test_ada_delegation(govtool_api, ada_holder_delegate_to_drep): | ||
print(ada_holder_delegate_to_drep) | ||
response = govtool_api.ada_holder_get_current_delegation(ada_holder_delegate_to_drep["stakeKey"]) | ||
resp = response.json() | ||
if resp: | ||
assert ada_holder_delegate_to_drep["drepId"] in resp | ||
|
||
|
||
def test_check_voting_power(govtool_api, ada_holder_delegate_to_drep): | ||
response = govtool_api.ada_holder_get_voting_power(ada_holder_delegate_to_drep["stakeKey"]) | ||
ada_holder_voting_power = response.json() | ||
assert isinstance(ada_holder_voting_power, int) |
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
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,78 @@ | ||
import json | ||
import time | ||
from typing import Any | ||
|
||
import requests | ||
from requests import Response | ||
|
||
from models.TestResult import Metrics | ||
from config import BUILD_ID | ||
|
||
|
||
class GovToolApi(): | ||
|
||
def __init__(self, base_url: str): | ||
self._base_url = base_url | ||
self._session = requests.Session() | ||
self._session.headers.update({"Accept": "application/json", "content-type": "application/json"}) | ||
self.requests_log = [] | ||
self.tests_log = [] | ||
|
||
def __request(self, method: str, endpoint: str, param: Any | None = None, | ||
body: Any | None = None) -> Response: | ||
endpoint = endpoint if endpoint.startswith('/') else '/' + endpoint | ||
full_url = self._base_url + endpoint | ||
full_url = full_url + "/" + param if param else full_url | ||
start_time = int(time.time()*1000000) | ||
|
||
response = self._session.request(method, full_url, json=body) | ||
|
||
end_time = int(time.time()*1000000) | ||
response_time = end_time - start_time | ||
|
||
try: | ||
response_json = json.dumps(response.json()) | ||
response_json_str = response_json[:200] | ||
except: | ||
response_json_str = "Something went wrong" | ||
|
||
request_info = { | ||
"method": method, | ||
"endpoint": endpoint, | ||
"path_param": param, | ||
"json": json.dumps(body), | ||
"status_code": response.status_code, | ||
"response_json": response_json_str, | ||
"response_time": response_time, | ||
"start_date": int(start_time), | ||
"build_id": BUILD_ID | ||
} | ||
|
||
self.requests_log.append(request_info) | ||
|
||
assert 200 >= response.status_code <= 299, f"Expected {method}{endpoint} to succeed but got statusCode:{response.status_code} : body:{response.text}" | ||
return response | ||
|
||
def __get(self, endpoint: str, param: str | None = None) -> Response: | ||
return self.__request('GET', endpoint, param) | ||
|
||
def drep_list(self) -> Response: | ||
return self.__get('/drep/list') | ||
|
||
def drep_getVotes(self, drep_id) -> Response: | ||
return self.__get('/drep/getVotes', drep_id) | ||
|
||
def drep_get_voting_power(self, drep_id) -> Response: | ||
return self.__get('/drep/get-voting-power', drep_id) | ||
|
||
def proposal_list(self) -> Response: | ||
return self.__get('/proposal/list') | ||
|
||
def ada_holder_get_current_delegation(self, stake_key: str) -> Response: | ||
return self.__get('/ada-holder/get-current-delegation', stake_key) | ||
|
||
def ada_holder_get_voting_power(self, stake_key) -> Response: | ||
return self.__get('/ada-holder/get-voting-power', stake_key) | ||
|
||
def add_test_metrics(self, metrics: Metrics): | ||
self.tests_log.append(metrics) |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.