Пример #1
0
    def setUpClass(self):
        self.dynamodbClient = boto3.client(
            'dynamodb', endpoint_url='http://localhost:8000')

        #clean up local DB before tests
        tables = self.dynamodbClient.list_tables()
        tableNames = tables.get('TableNames')
        try:
            for name in tableNames:
                dynamodb.Table(name).delete()
        except:
            print('Error deleting tableNames')

        classSettingsName = 'classes_settings.json'
        classMockData = 'mock_classes.json'
        settingsName = 'table_settings.json'
        mockData = 'mock_data.json'

        user_table = db.createTableFromFile('./tests/' + settingsName,
                                            dynamodb)
        class_table = db.createTableFromFile('./tests/' + classSettingsName,
                                             dynamodb)

        db.preloadClassData('./tests/' + classMockData, class_table)
        db.preloadDataFromFile('./tests/' + mockData, user_table)
Пример #2
0
    def test_preloadBookData(self):
        print("Running preloadBookData test case")
        booksSetting = 'book_settings.json'
        bookMockData = 'mock_book.json'

        booksTable = db.createTableFromFile('./tests/' + booksSetting,
                                            self.dynamodb)

        db.preloadBookData('./tests/' + bookMockData, booksTable)
        self.assertIsNotNone(
            booksTable.get_item(Key={
                'bookId': 'd6742cc-f02d-4fd6-80f0-026784g1ab9b'
            }).get('Item'))
Пример #3
0
  def setUpClass(self):
    self.dynamodbClient = boto3.client('dynamodb', endpoint_url='http://localhost:8000')

    #clean up local DB before tests
    tables = self.dynamodbClient.list_tables()
    tableNames = tables.get('TableNames')
    try:
      for name in tableNames:
        dynamodb.Table(name).delete()
    except:
      print('Error deleting tableNames')

    booksSetting = 'book_settings.json'
    classSetting = 'classes_settings.json'
    bookMockData = 'mock_book.json'
    classesMockData = 'mock_classes.json'

    self.booksTable = db.createTableFromFile('./tests/'+booksSetting, dynamodb)
    self.classesTable = db.createTableFromFile('./tests/'+classSetting, dynamodb)

    db.preloadBookData('./tests/'+bookMockData, self.booksTable)
    db.preloadClassData('./tests/'+classesMockData, self.classesTable)
Пример #4
0
    def test_preloadClassData(self):
        print("Running preloadClassData test case")
        classesSetting = 'classes_settings.json'
        classesMockData = 'mock_classes.json'

        classesTable = db.createTableFromFile('./tests/' + classesSetting,
                                              self.dynamodb)

        db.preloadClassData('./tests/' + classesMockData, classesTable)
        self.assertIsNotNone(
            classesTable.get_item(
                Key={
                    'code': 'd26713cc-f02d-4fd6-80f0-026784d1ab9b'
                }).get('Item'))
        self.assertIsNotNone(
            classesTable.get_item(
                Key={
                    'code': 'd93cd63f-6eda-4644-b603-60f51142749e'
                }).get('Item'))
        self.assertIsNotNone(
            classesTable.get_item(
                Key={
                    'code': '93211750-a753-41cc-b8dc-904d6ed2f931'
                }).get('Item'))
Пример #5
0
 def test_create_table_from_file_fail(self):
     print("Running create_table_from_file test fail test case")
     table = db.createTableFromFile(self.badSettingsName, self.dynamodb)
     self.assertIsNone(table)
Пример #6
0
 def test_create_table_from_file(self):
     print("Running create_table_from_file test")
     table = db.createTableFromFile(self.settingsName, self.dynamodb)
     self.assertIsNotNone(table)
     self.assertEqual(table.table_status, "ACTIVE")
     self.assertEqual(table.table_name, "testusers")