def test_dynamodb_backend_create(dynamodb_table): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.type': 'dynamodb', 'swag.namespace': 'accounts', 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678910', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } assert not swag.get_all() item = swag.create(account) assert swag.get("[?id=='{id}']".format(id=item['id']))
def test_s3_backend_get(s3_bucket_name): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.type': 's3', 'swag.bucket_name': s3_bucket_name, 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678910', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } swag.create(account) assert swag.get("[?id=='012345678910']")
def test_file_backend_update(temp_file_name): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.data_file': str(temp_file_name), 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678910', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } swag.create(account) account['aliases'] = ['test', 'prod'] swag.update(account) account = swag.get("[?id=='{id}']".format(id=account['id'])) assert account['aliases'] == ['test', 'prod']
def test_file_backend_get(vector_path): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.data_dir': vector_path, 'swag.namespace': 'valid_accounts_v2', 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) assert swag.get("[?id=='012345678910']")