def test_table_not_exist_exception_in_get_item(self): cluster_handler_mock = mock.Mock() cluster_handler_mock.execute_query.return_value = None table_repo = CassandraTableInfoRepository(cluster_handler_mock) context = mock.Mock(tenant='fake_tenant') with self.assertRaises(exception.TableNotExistsException) as raises_cm: table_repo.get(context, "nonexistenttable") ex = raises_cm.exception self.assertIn("Table 'nonexistenttable' does not exist", ex.message)
def test_set_last_updated_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_updated = datetime.now() - timedelta(0, 1000) table_repo.update(context, table_info) seconds = (datetime.now() - table_info.last_updated).total_seconds() self.assertLess(seconds, 30)