Пример #1
0
    def test_get_or_create_from_package(self):
        mock_session = self.mocker.mock()

        pkg_analyzer = doubles.PackageAnalyzerStub()
        pkg_analyzer.criteria = {
            'article_title': 'foo',
            'journal_eissn': '1234-1234',
            'journal_pissn': '1234-4321'
        }

        mock_session.query(ArticlePkg)
        self.mocker.result(mock_session)

        mock_session.filter_by(article_title='foo')
        self.mocker.result(mock_session)

        mock_session.one()
        self.mocker.result(ArticlePkg())

        self.mocker.replay()

        article_pkg = ArticlePkg.get_or_create_from_package(
            pkg_analyzer, mock_session)

        self.assertIsInstance(article_pkg, ArticlePkg)
Пример #2
0
    def test_property_issue_label_when_exists_only_year(self):
        """
        When exists only ``year`` the property must return something like: 2013
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014

        self.assertEqual(pkg_analyzer.issue_label, '2014')
Пример #3
0
    def test_property_issue_label_when_exists_only_year(self):
        """
        When exists only ``year`` the property must return something like: 2013
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014

        self.assertEqual(pkg_analyzer.issue_label, '2014')
Пример #4
0
    def test_property_issue_label_when_exists_year_suppl_number(self):
        """
        When exists only ``year``, ``supplement number`` and supplement of volume
        the property must return something like: 2014 suppl. N23
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_suppl_number = '23'

        self.assertEqual(pkg_analyzer.issue_label, '2014 suppl. N23')
Пример #5
0
    def test_property_issue_label_when_exists_only_year_and_number(self):
        """
        When exists only ``year`` and ``volume`` the property must return
        something like: 2013 V18
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_number = '5'

        self.assertEqual(pkg_analyzer.issue_label, '2014 N5')
Пример #6
0
    def test_property_issue_label_when_exists_year_suppl_number(self):
        """
        When exists only ``year``, ``supplement number`` and supplement of volume
        the property must return something like: 2014 suppl. N23
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_suppl_number = '23'

        self.assertEqual(pkg_analyzer.issue_label, '2014 suppl. N23')
Пример #7
0
    def test_property_issue_label_when_exists_only_year_and_number(self):
        """
        When exists only ``year`` and ``volume`` the property must return
        something like: 2013 V18
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_number = '5'

        self.assertEqual(pkg_analyzer.issue_label, '2014 N5')
Пример #8
0
    def test_property_issue_label_when_exists_year_volume_number(self):
        """
        When exists ``year``, ``volume`` and ``number`` must return something
        like: 2013 V18 N4.
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_volume = '31'
        pkg_analyzer.issue_number = '1'

        self.assertEqual(pkg_analyzer.issue_label, '2014 V31 N1')
Пример #9
0
    def test_property_issue_label_when_exists_year_volume_number(self):
        """
        When exists ``year``, ``volume`` and ``number`` must return something
        like: 2013 V18 N4.
        """
        pkg_analyzer = ArticlePkg()

        pkg_analyzer.issue_year = 2014
        pkg_analyzer.issue_volume = '31'
        pkg_analyzer.issue_number = '1'

        self.assertEqual(pkg_analyzer.issue_label, '2014 V31 N1')
Пример #10
0
    def test_get_or_create_from_package(self):
        mock_session = self.mocker.mock()

        pkg_analyzer = doubles.PackageAnalyzerStub()
        pkg_analyzer.criteria = {'article_title': 'foo', 'journal_eissn':'1234-1234', 'journal_pissn':'1234-4321'}

        mock_session.query(ArticlePkg)
        self.mocker.result(mock_session)

        mock_session.filter_by(article_title='foo')
        self.mocker.result(mock_session)

        mock_session.one()
        self.mocker.result(ArticlePkg())

        self.mocker.replay()

        article_pkg = ArticlePkg.get_or_create_from_package(pkg_analyzer, mock_session)

        self.assertIsInstance(article_pkg, ArticlePkg)