예제 #1
0
    def test_instatiation_without_issue(self):
        from .modelfactories import JournalFactory, IssueFactory
        from catalog.tools import Navigation

        mock_issue = self.mocker.mock()

        issues = [
            {
                u'id': 4,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 1,
                    u'id': 4,
                    u'publication_year': 2005,
                    u'volume': '47'
                },
            },
            {
                u'id': 6,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 3,
                    u'id': 6,
                    u'publication_year': 2005,
                    u'volume': '47'
                },
            },
            {
                u'id': 5,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 2,
                    u'id': 5,
                    u'publication_year': 2005,
                    u'volume': '47'
                },
            }
        ]

        issue = IssueFactory.build()
        mock_issue.get_issue(ANY, ANY)
        self.mocker.result(issue)
        self.mocker.replay()

        journal = JournalFactory.build(issues=issues)

        nav = Navigation(journal, issue_lib=mock_issue)
        nav._load_issue()

        self.assertEqual(nav._issue, issue)
예제 #2
0
    def test_instatiation_without_issue(self):
        from .modelfactories import JournalFactory, IssueFactory
        from catalog.tools import Navigation

        mock_issue = self.mocker.mock()

        issues = [
            {
                u'id': 4,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 1,
                    u'id': 4,
                },
            },
            {
                u'id': 6,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 3,
                    u'id': 6,
                },
            },
            {
                u'id': 5,
                u'data':
                {
                    u'total_documents': 3,
                    u'order': 2,
                    u'id': 5,
                },
            }
        ]

        issue = IssueFactory.build()
        mock_issue.get_issue(ANY, ANY)
        self.mocker.result(issue)
        self.mocker.replay()

        journal = JournalFactory.build(issues=issues)

        nav = Navigation(journal, issue_lib=mock_issue)
        nav._load_issue()

        self.assertEqual(nav._issues, OrderedDict([(1, 4), (2, 5), (3, 6)]))
        self.assertEqual(nav._current, 6)
        self.assertEqual(nav._issue, issue)