コード例 #1
0
    def test_no_record_in_control_table(self, create_coll, id_gen):

        dynamodb = boto3.resource('dynamodb')
        dynamodb_client = boto3.client('dynamodb')

        #create_RVA_COLLECTION_CONTROL_TABLE(dynamodb)

        print("\n\n##test_no_record_in_control_table\n" )

        r  = dynamodb_client.delete_item(
            TableName=RVA_COLLECTION_CONTROL_TABLE,
            Key={"Identifier": {"S": "COLLECTIONS_NEW"}},
            ReturnConsumedCapacity='TOTAL'
        )

        rcc = RekognitionCollectionController(RVA_COLLECTION_CONTROL_TABLE, 'COLLECTIONS_NEW')
        collection_id = rcc.fetch_collection()

        print("COLL ID: {}".format(collection_id))

        r  = dynamodb_client.get_item(
            TableName=RVA_COLLECTION_CONTROL_TABLE,
            Key={"Identifier": {"S": "COLLECTIONS_NEW"}},
            ConsistentRead=True,
            ReturnConsumedCapacity='TOTAL'
        )

        item = r['Item']

        assert "DVA-123456" == item['Current']['S'] 
        assert "DVA-123456" == collection_id
        assert 0 == int(item['Count']['N'])
コード例 #2
0
    def test_control_table_less_than_max_size(self, call):

        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_LESS"}},
            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-123456"}, 
                ':count': {'N': "100"},
                ':coll_id': {'L': [ { "S" : "DVA-123456" } ] }
            }
        )

        rcc = RekognitionCollectionController(RVA_COLLECTION_CONTROL_TABLE, 'COLLECTIONS_LESS')
        collection_id = rcc.fetch_collection()
       
        r  = dynamodb_client.get_item(
            TableName=RVA_COLLECTION_CONTROL_TABLE,
            Key={"Identifier": {"S": "COLLECTIONS_LESS"}},
            ConsistentRead=True,
            ReturnConsumedCapacity='TOTAL'
        )

        item = r['Item']

        print("\n\n##test_control_table_less_than_max_size\n")
        print("\n\n>>>>>>\n\n\n")
        print(json.dumps(item))

        self.assertEqual("DVA-123456", item['Current']['S'], msg="Data written in DDB is wrong. Exp: {} Found: {}".format("DVA-123456", item['Current']['S']))
        self.assertEqual("DVA-123456", collection_id, msg="Data written in DDB is wrong. Exp: {} Found: {}".format("DVA-123456", collection_id))
        self.assertEqual(100, int(item['Count']['N']), msg="Data written in DDB is wrong. Exp: {} Found: {}".format(100, int(item['Count']['N'])))