def test_fs_response_instance(): context = DummyContext() resp = ProjectFSResponse(context) assert resp.context == context assert resp.response_types == FS_RESPONSE.keys() assert resp.has_failed is False assert resp.made_changes is False assert list(resp.failed()) == [] assert list(resp.completed()) == [] assert str(resp) == ( "<ProjectFSResponse(<DummyContext object>): No changes made>") assert list(resp) == [] with pytest.raises(KeyError): resp["DOES_NOT_EXIST"]
def _test_fs_response(expected=2, **kwargs): action_type = kwargs.pop("action_type") state_type = kwargs.pop("state_type") resp = ProjectFSResponse(DummyContext()) state = DummyFSState(DummyContext(), **kwargs) for fs_state in state[state_type]: resp.add(action_type, fs_state=fs_state) assert resp.has_failed is False assert resp.made_changes is True assert resp.response_types == FS_RESPONSE.keys() assert len(list(resp.completed())) == 2 assert list(resp.failed()) == [] assert action_type in resp assert str(resp) == ("<ProjectFSResponse(<DummyContext object>): %s: %s>" % (action_type, expected)) for i, item in enumerate(resp[action_type]): _test_item(item, state[state_type][i])
def _test_fs_response(expected=2, **kwargs): action_type = kwargs.pop("action_type") state_type = kwargs.pop("state_type") resp = ProjectFSResponse(DummyContext()) state = DummyFSState(DummyContext(), **kwargs) for fs_state in state[state_type]: resp.add(action_type, fs_state=fs_state) assert resp.has_failed is False assert resp.made_changes is True assert resp.response_types == FS_RESPONSE.keys() assert len(list(resp.completed())) == 2 assert list(resp.failed()) == [] assert action_type in resp assert str(resp) == ( "<ProjectFSResponse(<DummyContext object>): %s: %s>" % (action_type, expected)) for i, item in enumerate(resp[action_type]): _test_item(item, state[state_type][i])