def test_since_to_timedelta(self): td = StateDB.since_to_timedelta('1d') assert (td.days == 1) td = StateDB.since_to_timedelta('1h') assert (td.seconds == 3600) td = StateDB.since_to_timedelta('10m') assert (td.seconds == 600)
def setUpClass(cls): cls.statedb = StateDB(table_name) cls.statedb.create_item(test_item, state='QUEUED') for i, s in enumerate(STATES): newitem = deepcopy(test_item) newitem['id'] = newitem['id'] + str(i) cls.statedb.create_item(newitem, state=s)
from cirruslib.transfer import get_s3_session from cirruslib.utils import get_path from traceback import format_exc from typing import Dict, Optional, List # envvars LOG_LEVEL = os.getenv('CIRRUS_LOG_LEVEL', 'INFO') DATA_BUCKET = os.getenv('CIRRUS_DATA_BUCKET', None) CATALOG_BUCKET = os.getenv('CIRRUS_CATALOG_BUCKET', None) PUBLISH_TOPIC_ARN = os.getenv('CIRRUS_PUBLISH_TOPIC_ARN', None) logger = logging.getLogger(__name__) logger.setLevel(LOG_LEVEL) # clients statedb = StateDB() snsclient = boto3.client('sns') stepfunctions = boto3.client('stepfunctions') class Catalog(dict): def __init__(self, *args, update=False, state_item=None, **kwargs): """Initialize a Catalog, verify required fields, and assign an ID Args: state_item (Dict, optional): Dictionary of entry in StateDB. Defaults to None. """ super(Catalog, self).__init__(*args, **kwargs) if update: self.update()
def setUpClass(cls): cls.statedb = StateDB(table_name) for i in range(10): newitem = deepcopy(test_item) newitem['id'] = newitem['id'] + str(i) cls.statedb.create_item(newitem)
def test_dbitem_to_item(self): item = StateDB.dbitem_to_item(test_dbitem) assert (item['catid'] == test_item['id']) assert (item['workflow'] == 'test') assert (item['state'] == 'QUEUED')
def test_get_input_catalog_url(self): url = StateDB.get_input_catalog_url(self.testkey) assert (f"{test_item['id']}/input.json" in url)
def test_key_to_catid(self): catid = StateDB.key_to_catid(self.testkey) assert (catid == test_item['id'])
def test_catid_to_key(self): key = StateDB.catid_to_key(test_item['id']) assert (key['input_collections'] == "input-collection") assert (key['id'] == 'test/item')