def test_list_tables(): name = "TestTable" # {'schema': } dynamodb_backend2.create_table( name, schema=[{"KeyType": "HASH", "AttributeName": "forum_name"}, {"KeyType": "RANGE", "AttributeName": "subject"}], ) conn = boto.dynamodb2.connect_to_region("us-west-2", aws_access_key_id="ak", aws_secret_access_key="sk") assert conn.list_tables()["TableNames"] == [name]
def test_list_tables(): name = 'TestTable' #{'schema': } dynamodb_backend2.create_table(name,schema=[ {u'KeyType': u'HASH', u'AttributeName': u'forum_name'}, {u'KeyType': u'RANGE', u'AttributeName': u'subject'} ]) conn = boto.dynamodb2.connect_to_region( 'us-west-2', aws_access_key_id="ak", aws_secret_access_key="sk") assert conn.list_tables()["TableNames"] == [name]
def test_list_tables_layer_1(): dynamodb_backend2.create_table("test_1", schema=[{"KeyType": "HASH", "AttributeName": "name"}]) dynamodb_backend2.create_table("test_2", schema=[{"KeyType": "HASH", "AttributeName": "name"}]) conn = boto.dynamodb2.connect_to_region("us-west-2", aws_access_key_id="ak", aws_secret_access_key="sk") res = conn.list_tables(limit=1) expected = {"TableNames": ["test_1"], "LastEvaluatedTableName": "test_1"} res.should.equal(expected) res = conn.list_tables(limit=1, exclusive_start_table_name="test_1") expected = {"TableNames": ["test_2"]} res.should.equal(expected)
def test_list_tables_layer_1(): dynamodb_backend2.create_table("test_1",schema=[ {u'KeyType': u'HASH', u'AttributeName': u'name'} ]) dynamodb_backend2.create_table("test_2",schema=[ {u'KeyType': u'HASH', u'AttributeName': u'name'} ]) conn = boto.dynamodb2.connect_to_region( 'us-west-2', aws_access_key_id="ak", aws_secret_access_key="sk") res = conn.list_tables(limit=1) expected = {"TableNames": ["test_1"], "LastEvaluatedTableName": "test_1"} res.should.equal(expected) res = conn.list_tables(limit=1, exclusive_start_table_name="test_1") expected = {"TableNames": ["test_2"]} res.should.equal(expected)
def test_list_tables_layer_1(): # Should make tables properly with boto dynamodb_backend2.create_table("test_1", schema=[ {u'KeyType': u'HASH', u'AttributeName': u'name'} ]) dynamodb_backend2.create_table("test_2", schema=[ {u'KeyType': u'HASH', u'AttributeName': u'name'} ]) conn = boto.dynamodb2.connect_to_region( 'us-east-1', aws_access_key_id="ak", aws_secret_access_key="sk") res = conn.list_tables(limit=1) expected = {"TableNames": ["test_1"], "LastEvaluatedTableName": "test_1"} res.should.equal(expected) res = conn.list_tables(limit=1, exclusive_start_table_name="test_1") expected = {"TableNames": ["test_2"]} res.should.equal(expected)
def client(): with mock_dynamodb2(): schema = task_schema["KeySchema"] indexes = task_schema["GlobalSecondaryIndexes"] dynamodb_backend2.create_table("test", schema=schema, indexes=indexes) schema = release_summary_schema["KeySchema"] dynamodb_backend2.create_table( "release-summary", schema=schema, indexes=[] ) schema = study_summary_schema["KeySchema"] indexes = study_summary_schema["GlobalSecondaryIndexes"] dynamodb_backend2.create_table( "study-summary", schema=schema, indexes=indexes ) app = create_app() app.config["DYNAMO_ENDPOINT"] = None app.config["TASK_TABLE"] = "test" app.config["RELEASE_SUMMARY_TABLE"] = "release-summary" app.config["DATASERVICE_URL"] = "http://dataservice" app.config["COORDINATOR_URL"] = "http://coordinator" app.config["EGO_URL"] = "http://ego" app.config[ "AUTH0_AUD" ] = "https://kf-release-coordinator.kidsfirstdrc.org" app_context = app.app_context() app_context.push() client = app.test_client() # Allow all requests to be verified by ego mock_resp = MagicMock() mock_resp.json.return_value = True mock_resp.status_code = 200 with patch("reports.authentication.requests.get") as mock_get: mock_get.return_value = mock_resp yield client
def mock_dynamo_table(): dynamodb_backend2.create_table(ENV['DYNAMODB_TABLE_NAME'], schema=[{ "AttributeName": "DataID", "KeyType": "HASH" }])