def test_update_status_on_describe_for_deleting_table_negative(
            self, mock_repo_get, mock_repo_update):

        context = mock.Mock(tenant='fake_tenant')
        table_name = 'fake_table'
        storage_manager = SimpleStorageManager(None, TableInfoRepository())

        table_info = TableInfo(table_name, None, None,
                               TableMeta.TABLE_STATUS_DELETING)
        table_info.last_update_date_time = datetime.now()

        mock_repo_get.return_value = table_info

        table_meta = storage_manager.describe_table(context, table_name)

        self.assertEqual(table_meta.status, TableMeta.TABLE_STATUS_DELETING)
    def test_update_status_on_describe_for_deleting_table_negative(
            self, mock_repo_get, mock_repo_update):

        context = mock.Mock(tenant='fake_tenant')
        table_name = 'fake_table'
        storage_manager = SimpleStorageManager(None, TableInfoRepository())

        table_info = TableInfo(
            table_name, None, TableMeta.TABLE_STATUS_DELETING)
        table_info.last_update_date_time = datetime.now()

        mock_repo_get.return_value = table_info

        table_meta = storage_manager.describe_table(context, table_name)

        self.assertEqual(
            table_meta.status, TableMeta.TABLE_STATUS_DELETING)
    def test_set_last_update_date_time_on_update(self):
        cluster_handler_mock = mock.Mock()
        cluster_handler_mock.execute_query.return_value = [{'[applied]': True}]
        table_repo = CassandraTableInfoRepository(cluster_handler_mock)
        context = mock.Mock(tenant='fake_tenant')

        table_schema = mock.Mock()
        table_schema.to_json.return_value = ''

        table_info = TableInfo(
            'fake_table', table_schema, TableMeta.TABLE_STATUS_CREATING)
        table_info.last_update_date_time = datetime.now() - timedelta(0, 1000)
        table_repo.update(context, table_info)

        seconds = (datetime.now() -
                   table_info.last_update_date_time).total_seconds()
        self.assertLess(seconds, 30)
Example #4
0
    def test_set_last_update_date_time_on_update(self):
        cluster_handler_mock = mock.Mock()
        cluster_handler_mock.execute_query.return_value = [{'[applied]': True}]
        table_repo = CassandraTableInfoRepository(cluster_handler_mock)
        context = mock.Mock(tenant='fake_tenant')

        table_schema = mock.Mock()
        table_schema.to_json.return_value = ''

        table_info = TableInfo('fake_table',
                               '00000000-0000-0000-0000-000000000000',
                               table_schema, TableMeta.TABLE_STATUS_CREATING)
        table_info.last_update_date_time = datetime.now() - timedelta(0, 1000)
        table_repo.update(context, table_info)

        seconds = (datetime.now() -
                   table_info.last_update_date_time).total_seconds()
        self.assertLess(seconds, 30)