Something went wrong on our end
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
integration_test_utils.py 1.64 KiB
import glob
import json
from datetime import datetime
from zipfile import ZipFile
class IntegrationTestUtils:
DEFAULT_CONFIG_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json"
TEMP_CONFIG_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/workspace/temp_config.json"
EXAMPLE_SURVEY_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/resources/coordinator/assets/example_survey_run.zip"
EXAMPLE_DEPO_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/resources/coordinator/assets/example_depo_run.zip"
EXAMPLE_ENV_SUIT_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/resources/coordinator/assets/example_env_suit_run.zip"
@staticmethod
def load_json_file(file: str) -> dict:
with open(file) as config_file:
config: dict = json.load(config_file)
return config
@staticmethod
def write_json_file(values: dict, file: str):
with open(file, 'w') as file:
json.dump(values, file, indent = 4)
@staticmethod
def get_now_string() -> str:
nowstring: str = datetime.today().strftime('%Y-%m-%d_%H%M%S')
return nowstring
@staticmethod
def unpack_zip(zip_to_unpack: str, out_file: str):
with ZipFile(zip_to_unpack) as zf: # open the zip file
for target_file in zf.namelist(): # check if the file exists in the archive
zf.extract(target_file, out_file)
@staticmethod
def count_files_in_wildcard(wildcard: str) -> int:
results = glob.glob(wildcard)
return len(results)