def test_increment_collection_count(self, call, id_gen): dynamodb = boto3.resource('dynamodb') dynamodb_client = boto3.client('dynamodb') #create_RVA_COLLECTION_CONTROL_TABLE(dynamodb) dynamodb_client.update_item( TableName=RVA_COLLECTION_CONTROL_TABLE, Key={"Identifier": {"S": "COLLECTIONS_INC"}}, UpdateExpression="SET #curr = :newvalue, #cnt = :count, #cols = :coll_id", #list_append(if_not_exists(#cols, :empty_list), :coll_id)", ExpressionAttributeNames={ '#curr': 'Current', '#cnt': 'Count', '#cols': 'CollectionIds' }, ExpressionAttributeValues={ ':newvalue': {'S': "DVA-000000"}, ':count': {'N': "1234"}, ':coll_id': {'L': [ { "S" : "DVA-000000" }, { "S" : "DVA-000001" }, { "S" : "DVA-000002" } ] } } ) rcc = RekognitionCollectionController(RVA_COLLECTION_CONTROL_TABLE, 'COLLECTIONS_INC') r = rcc.increment_collection_count("DVA-000000", 1000) print("\n\UPDATE COUNT\n\n\n") print(r) self.assertEqual(2234, r, msg="Data written in DDB is wrong. Exp: {} Found: {}".format("", ""))
def update_collection_control(collection_id, faces_indexed): rcc = RekognitionCollectionController(RVA_COLLECTION_CONTROL, 'COLLECTIONS') rcc.increment_collection_count(collection_id, faces_indexed)