def test_proxies_to_GroupJSONPresenter( self, factories, GroupJSONPresenter_): # noqa: [N802, N803] groups = [factories.Group(), factories.OpenGroup()] route_url = mock.Mock() presenter = GroupsJSONPresenter(groups, route_url=route_url) expected_call_args = [mock.call(group, route_url) for group in groups] presenter.asdicts() assert GroupJSONPresenter_.call_args_list == expected_call_args
def test_proxies_to_GroupJSONPresenter(self, factories, GroupJSONPresenter_, links_svc): # noqa: [N802, N803] groups = [factories.Group(), factories.OpenGroup()] presenter = GroupsJSONPresenter(groups, links_svc=links_svc) expected_call_args = [mock.call(group, links_svc) for group in groups] presenter.asdicts() assert GroupJSONPresenter_.call_args_list == expected_call_args
def test_proxies_to_GroupJSONPresenter(self, factories, GroupJSONPresenter_, GroupContexts): groups = [factories.Group(), factories.OpenGroup()] group_contexts = GroupContexts(groups) presenter = GroupsJSONPresenter(group_contexts) expected_call_args = [ mock.call(group_context) for group_context in group_contexts ] presenter.asdicts() assert GroupJSONPresenter_.call_args_list == expected_call_args
def test_proxies_to_GroupJSONPresenter( self, factories, GroupJSONPresenter_, GroupResources): # noqa: [N802, N803] groups = [factories.Group(), factories.OpenGroup()] group_resources = GroupResources(groups) presenter = GroupsJSONPresenter(group_resources) expected_call_args = [ mock.call(group_resource) for group_resource in group_resources ] presenter.asdicts() assert GroupJSONPresenter_.call_args_list == expected_call_args
def test_proxies_to_GroupJSONPresenter( self, factories, GroupJSONPresenter_, GroupContexts ): groups = [factories.Group(), factories.OpenGroup()] group_contexts = GroupContexts(groups) presenter = GroupsJSONPresenter(group_contexts) expected_call_args = [ mock.call(group_context) for group_context in group_contexts ] presenter.asdicts() assert GroupJSONPresenter_.call_args_list == expected_call_args
def test_asdicts_returns_list_of_dicts(self, factories, GroupContexts): groups = [factories.Group(name="filbert"), factories.OpenGroup(name="delbert")] group_contexts = GroupContexts(groups) presenter = GroupsJSONPresenter(group_contexts) result = presenter.asdicts() assert [group["name"] for group in result] == ["filbert", "delbert"]
def test_asdicts_injects_urls(self, factories, links_svc): groups = [factories.Group(), factories.OpenGroup()] presenter = GroupsJSONPresenter(groups, links_svc) result = presenter.asdicts() for group_model in result: assert 'urls' in group_model
def test_asdicts_injects_links(self, factories, links_svc, GroupContexts): groups = [factories.Group(), factories.OpenGroup()] group_contexts = GroupContexts(groups) presenter = GroupsJSONPresenter(group_contexts) result = presenter.asdicts() for group_model in result: assert "links" in group_model
def test_asdicts_returns_list_of_dicts(self, factories): groups = [ factories.Group(name=u'filbert'), factories.OpenGroup(name=u'delbert') ] presenter = GroupsJSONPresenter(groups) result = presenter.asdicts() assert [group['name'] for group in result] == [u'filbert', u'delbert']
def test_asdicts_injects_urls(self, factories): route_url = mock.Mock(return_value='/group/a') groups = [factories.Group(), factories.OpenGroup()] presenter = GroupsJSONPresenter(groups, route_url) result = presenter.asdicts() for group in result: assert group['url'] assert group['urls']['group']
def test_asdicts_returns_list_of_dicts(self, factories, GroupContexts): groups = [ factories.Group(name='filbert'), factories.OpenGroup(name='delbert') ] group_contexts = GroupContexts(groups) presenter = GroupsJSONPresenter(group_contexts) result = presenter.asdicts() assert [group['name'] for group in result] == ['filbert', 'delbert']
def test_asdicts_injects_urls(self, factories, links_svc, GroupResources): # noqa: N803 groups = [factories.Group(), factories.OpenGroup()] group_resources = GroupResources(groups) presenter = GroupsJSONPresenter(group_resources) result = presenter.asdicts() for group_model in result: assert 'urls' in group_model assert 'links' in group_model
def test_it(self, factories, pyramid_request, GroupJSONPresenter): group = factories.Group() presenter = GroupsJSONPresenter(groups=[group], request=pyramid_request) result = presenter.asdicts(expand=sentinel.expand) GroupJSONPresenter.assert_called_once_with(group, pyramid_request) GroupJSONPresenter.return_value.asdict.assert_called_once_with( expand=sentinel.expand) assert result == [GroupJSONPresenter.return_value.asdict.return_value]