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)
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')
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')
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')
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')
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)