def test_get_from_package(self): mock_session = self.mocker.mock() self.mocker.replay() pkg_analyzer = doubles.PackageAnalyzerStub() pkg_analyzer.is_valid_meta = lambda *args, **kwargs: True attempt = Attempt.get_from_package(pkg_analyzer) self.assertIsInstance(attempt, Attempt)
def test_get_from_package_not_valid_if_invalid(self): mock_session = self.mocker.mock() self.mocker.replay() pkg_analyzer = doubles.PackageAnalyzerStub() pkg_analyzer.meta = {'journal_eissn': '1234-1234', 'journal_pissn': '4321-1234'} pkg_analyzer.is_valid_meta = lambda *args, **kwargs: True pkg_analyzer.is_valid_package = lambda *args, **kwargs: False attempt = Attempt.get_from_package(pkg_analyzer) self.assertFalse(attempt.is_valid)
def test_get_from_package_not_valid_for_missing_meta(self): mock_session = self.mocker.mock() self.mocker.replay() pkg_analyzer = doubles.PackageAnalyzerStub() pkg_analyzer.meta = {'journal_eissn': None, 'journal_pissn': None, 'article_title': None} pkg_analyzer.is_valid_meta = lambda *args, **kwargs: False attempt = Attempt.get_from_package(pkg_analyzer) self.assertFalse(attempt.is_valid)
def test_get_from_package_not_valid_if_invalid(self): mock_session = self.mocker.mock() self.mocker.replay() pkg_analyzer = doubles.PackageAnalyzerStub() pkg_analyzer.meta = { 'journal_eissn': '1234-1234', 'journal_pissn': '4321-1234' } pkg_analyzer.is_valid_meta = lambda *args, **kwargs: True pkg_analyzer.is_valid_package = lambda *args, **kwargs: False attempt = Attempt.get_from_package(pkg_analyzer) self.assertFalse(attempt.is_valid)
def test_get_from_package_not_valid_for_missing_meta(self): mock_session = self.mocker.mock() self.mocker.replay() pkg_analyzer = doubles.PackageAnalyzerStub() pkg_analyzer.meta = { 'journal_eissn': None, 'journal_pissn': None, 'article_title': None } pkg_analyzer.is_valid_meta = lambda *args, **kwargs: False attempt = Attempt.get_from_package(pkg_analyzer) self.assertFalse(attempt.is_valid)