def test_drop_group(self) -> None: with self.db_adapter: token = ExampleStore.data_token assert_that(self.db_adapter.has_group(token.data_group), equal_to(False)) assert_that(self.db_adapter.has_group_table(token), equal_to(False)) self.db_adapter.create_group(token.data_group) self.db_adapter.create_group_table(token, ExampleStore) test_metadata = ExampleMetadata( test_str="test", test_int=123, test_float=0.123, test_bool=True, test_timestamp=datetime.now(), ) self.db_adapter._update_group_table_metadata(token, test_metadata) assert_that(self.db_adapter.has_group(token.data_group), equal_to(True)) assert_that(self.db_adapter.has_group_table(token), equal_to(True)) assert_that( self.db_adapter.get_group_table_metadata( token, ExampleMetadata), not_(equal_to(None)), ) with self.db_adapter: assert_that(self.db_adapter.has_group(token.data_group), equal_to(True)) assert_that(self.db_adapter.has_group_table(token), equal_to(True)) assert_that( self.db_adapter.get_group_table_metadata( token, ExampleMetadata), not_(equal_to(None)), ) with self.db_adapter: self.db_adapter.drop_group(token.data_group) assert_that(self.db_adapter.has_group(token.data_group), equal_to(False)) assert_that(self.db_adapter.has_group_table(token), equal_to(False)) assert_that( self.db_adapter.get_group_table_metadata( token, ExampleMetadata), equal_to(None), )
def test_delete_group_metadata(self) -> None: with self.db_adapter: test_metadata = ExampleMetadata( test_str="test", test_int=123, test_float=0.123, test_bool=True, test_timestamp=datetime.now(), ) token1 = DataToken("test1", RAW_GROUP) token2 = DataToken("test2", RAW_GROUP) self.db_adapter._update_group_table_metadata(token1, test_metadata) self.db_adapter._update_group_table_metadata(token2, test_metadata) assert_that( self.db_adapter.get_group_table_metadata( token1, ExampleMetadata), not_(equal_to(None)), ) assert_that( self.db_adapter.get_group_table_metadata( token2, ExampleMetadata), not_(equal_to(None)), ) self.db_adapter._delete_group_metadata(RAW_GROUP) assert_that( self.db_adapter.get_group_table_metadata( token1, ExampleMetadata), equal_to(None), ) assert_that( self.db_adapter.get_group_table_metadata( token2, ExampleMetadata), equal_to(None), )
def test_task_failure_recovers(): """Tests that if a task is KILLED, another one will be launched with a different ID.""" app_def = apps.sleep_app() app_def['cmd'] = 'sleep 1000' app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) deployment_wait(service_id=app_id) tasks = client.get_tasks(app_id) old_task_id = tasks[0]['id'] host = tasks[0]['host'] common.kill_process_on_host(host, '[s]leep 1000') assert_that(lambda: client.get_tasks(app_id)[0], eventually(has_value('id', not_(equal_to(old_task_id))), max_attempts=30))
def test_task_failure_recovers(): """Tests that if a task is KILLED, another one will be launched with a different ID.""" app_def = apps.sleep_app() app_def['cmd'] = 'sleep 1000' app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) common.deployment_wait(service_id=app_id) tasks = client.get_tasks(app_id) old_task_id = tasks[0]['id'] host = tasks[0]['host'] common.kill_process_on_host(host, '[s]leep 1000') assert_that(lambda: client.get_tasks(app_id)[0], eventually(has_value('id', not_(equal_to(old_task_id))), max_attempts=30))
def matches_when_negated_matcher_does_not_match(): assert_equal(matched(), not_(equal_to(1)).match(2))
def description_includes_description_of_negated_matcher(): assert_equal("not: 'hello'", not_(equal_to("hello")).describe())
def does_not_match_when_negated_matcher_matches(): assert_equal(unmatched("matched: 1"), not_(equal_to(1)).match(1))