def test_Agave_init(self, mock_get_tenants, mock_input): """ Test Agave initialization """ # Patch list_tenants function and input. mock_input.return_value = sample_tenants_list_response mock_get_tenants.return_value = "sd2e" # Instantiate Agave object making reference to local mock server. ag = Agave() ag.init() assert ag.tenant_id == "sd2e" assert ag.api_server == "https://api.sd2e.org"
def test_save_configs(self, mock_get_tenants): """ Test Agave initialization """ # Patch list_tenants function and input. mock_get_tenants.return_value = sample_tenants_list_response # Instantiate Agave objects and save configurations to cache dir. try: # create a tmp dir and use it as a cache dir. cache_dir = tempfile.mkdtemp() a = Agave(tenant_id="sd2e") a.init() a.client_name = "client-1" a.username = "******" a.save_configs(cache_dir) b = Agave(tenant_id="tacc.prod") b.init() b.client_name = "client-2" b.username = "******" b.save_configs(cache_dir) c = Agave(tenant_id="sd2e") c.init() c.client_name = "client-3" c.username = "******" c.save_configs(cache_dir) with open("{}/config.json".format(cache_dir), "r") as f: config = json.load(f) print(config) print() print(sample_config) assert config == sample_config finally: shutil.rmtree(cache_dir)
def test_save_configs(self, mock_get_tenants): """ Test Agave initialization """ # Patch list_tenants function and input. mock_get_tenants.return_value = sample_tenants_list_response # Instantiate Agave objects and save configurations to cache dir. try: # create a tmp dir and use it as a cache dir. cache_dir = tempfile.mkdtemp() a = Agave(tenant_id="sd2e") a.init() a.client_name = "client-1" a.username = "******" a.save_configs(cache_dir) b = Agave(tenant_id="tacc.prod") b.init() b.client_name = "client-2" b.username = "******" b.save_configs(cache_dir) c = Agave(tenant_id="sd2e") c.init() c.client_name = "client-3" c.username = "******" c.save_configs(cache_dir) with open("{}/config.json".format(cache_dir), "r") as f: config = json.load(f) print(config) print() print(sample_config) assert config == sample_config finally: shutil.rmtree(cache_dir)