async def test_run(self, event_loop): change = SetAnnotationsChange(1, [], params={ "id": "id", "entity-type": "entity_type", "annotations": "annotations" }) entity = mock.Mock() entity.set_annotations = base.AsyncMock(return_value="annotations1") state = mock.Mock() state.get_entity = mock.Mock(return_value=entity) model = mock.Mock() model.state = state context = mock.Mock() context.resolve = mock.Mock(side_effect=['application1']) context.model = model result = await change.run(context) assert result == "annotations1" entity.set_annotations.assert_called_once() entity.set_annotations.assert_called_with("annotations")
def test_list_params(self): change = SetAnnotationsChange(1, [], params=["id", "entity_type", "annotations"]) self.assertEqual({"change_id": 1, "requires": [], "id": "id", "entity_type": "entity_type", "annotations": "annotations"}, change.__dict__)
def test_dict_params_missing_data(self): change = SetAnnotationsChange(1, [], params={"id": "id", "entity-type": "entity_type"}) self.assertEqual({"change_id": 1, "requires": [], "id": "id", "entity_type": "entity_type", "annotations": None}, change.__dict__)
def test_method(self): self.assertEqual("setAnnotations", SetAnnotationsChange.method())