def test_pool_are_in_pool_to_json(self): pool = Pool(self.conn, "pool-name", "profile") pool.completion_ttl = "4.11:08:06" pool.auto_delete = True json_pool = pool._to_json() assert json_pool['completionTimeToLive'] == '4.11:08:06' assert json_pool['autoDeleteOnCompletion'] == True
def test_advance_bucket_in_pool_to_json(self): pool = Pool(self.conn, "pool-name", "profile") bucket = Bucket(self.conn, "name", False) bucket2 = bucket.with_filtering( BucketPrefixFiltering("prefix1")).with_resource_transformation( PrefixResourcesTransformation("prefix2")) pool.resources.append(bucket2) json_pool = pool._to_json() json_bucket = json_pool["advancedResourceBuckets"][0] assert "name" == json_bucket["bucketName"] assert "prefix1" == json_bucket["filtering"]["prefixFiltering"][ "prefix"] assert "prefix2" == json_bucket["resourcesTransformation"][ "stripPrefix"]["prefix"]
def test_pool_privileges(self): pool = Pool(self.conn, "pool-name", "profile") pool.allow_credentials_to_be_exported_to_pool_environment() assert pool.privileges is not None assert pool.privileges._exportApiAndStorageCredentialsInEnvironment == True json_pool = pool._to_json() assert json_pool['privileges'] is not None assert json_pool['privileges'][ 'exportApiAndStorageCredentialsInEnvironment'] is True # fields that need to be non null for the deserialization to not fail json_pool['creationDate'] = datetime.datetime.utcnow().strftime( "%Y-%m-%dT%H:%M:%SZ") json_pool['uuid'] = str(uuid.uuid4()) json_pool['state'] = 'Submitted' pool_from_json = Pool(self.conn, "pool-name", "profile") pool_from_json._update(json_pool) assert pool_from_json.privileges is not None assert pool_from_json.privileges._exportApiAndStorageCredentialsInEnvironment is True
def test_pool_property_send_to_json_representation(self, property_name, expected_value): pool = Pool(self.conn, "pool-name", "profile") pool._update(default_json_pool) pool_json = pool._to_json() assert pool_json[property_name] == expected_value