def test_using_profile(self): # Create profile for testing api = ProfileApi() profile = loadJSON("requests/profile-1.json") self.profile_uuid = api.profile_create(json.dumps(profile)) # # Test creation with only profile ID self.client.instance_new() assert re.match( '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', self.client.si_uuid) intent = loadJSON("requests/request-profile.json") intent["profileID"] = self.profile_uuid response = self.client.instance_create(json.dumps(intent)) # print(response) assert self.client.si_uuid in response self.client.instance_delete() self.client.si_uuid = None # # Test editable field overwrite uri_1 = "urn:ogf:network:maxgigapop.net:2013:180-134.research.maxgigapop.net" uri_2 = "urn:ogf:network:maxgigapop.net:2013:s0:1_1:wash-cr5" path_1 = profile["edit"][0]["path"] path_2 = profile["edit"][1]["path"] query = dict([("ask", "edit"), ("options", [dict([(path_1, uri_1), (path_2, uri_2)])])]) intent["queries"] = [query] print(intent) self.client.instance_new() response = self.client.instance_create(json.dumps(intent)) status = self.client.instance_get_status() print(f'create status={status}') assert 'CREATE - COMPILED' in status intentAPI = IntentApi() intentAPI.si_uuid = self.client.si_uuid intents = intentAPI.instance_get_intents() assert self.client.si_uuid in response assert uri_1 in intents assert uri_2 in intents self.client.instance_delete() self.client.si_uuid = None # TODO: no permission for profiles by other user # Clean-up single use profile api.profile_delete(self.profile_uuid) self.profile_uuid = None
def setUp(self) -> None: self.client = IntentApi() self.instance_client = InstanceApi() self.instance_client.instance_new() input = loadJSON("requests/request-1.json") self.instance_client.instance_create(json.dumps(input)) self.client.si_uuid = self.instance_client.si_uuid
def test_create_profile(self): # - TESTING: POST / profile = loadJSON("requests/profile-1.json") res = self.client.profile_create(json.dumps(profile)) # print(f'ADD: {res}') assert re.match( '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', res) TestProfileApi.uuids.append(res)
def test_update_profile(self): # PRE-OP: create profile for modification test. self.test_create_profile() uuid = TestProfileApi.uuids[-1] # # # - TESTING: PUT /{uuid} input = loadJSON("requests/profile-2.json") self.client.profile_update(json.dumps(input), uuid) prof = json.loads(self.client.profile_describe(uuid)) assert prof.get('name') == input.get('name')
def test_profile_license(self): # PRE-OP: create profile for deletion test. self.test_create_profile() uuid = TestProfileApi.uuids[-1] # # # - TESTING: POST /{uuid}/licenses license = loadJSON("requests/profile-license-1.json") self.client.profile_add_licenses(json.dumps(license), uuid) prof = json.loads(self.client.profile_describe(uuid)) assert len(prof.get('licenses')) == 1 # # - TESTING: PUT /{uuid}/licenses license.update({"remaining": 99}) self.client.profile_update_licenses(json.dumps(license), uuid) prof = json.loads(self.client.profile_describe(uuid)) assert prof.get('licenses')[0].get('remaining') == 99 license.update({"remaining": 0}) self.client.profile_update_licenses(json.dumps(license), uuid) prof = json.loads(self.client.profile_describe(uuid)) assert len(prof.get('licenses')) == 0
def preOpCreate(cls): paths = ["requests/profile-1.json", "requests/profile-2.json"] for path in paths: profile = loadJSON(path) res = cls.client.profile_create(json.dumps(profile)) cls.uuids.append(res)