def test_get_attempt_failure(self): """ Attempt is already registered """ self.assertIsInstance(checkin.get_attempt('samples/0042-9686-bwho-91-08-545.zip'), models.Attempt) self.assertRaises(excepts.DuplicatedPackage, lambda: checkin.get_attempt('samples/0042-9686-bwho-91-08-545.zip'))
def test_get_attempt_failure(self): """ Attempt is already registered """ safe_package = doubles.SafePackageStub(SAMPLE_PACKAGE, '/tmp/') self.assertIsInstance(checkin.get_attempt(safe_package), models.Attempt) self.assertRaises(excepts.DuplicatedPackage, lambda: checkin.get_attempt(safe_package))
def test_get_attempt_ok(self): """ Attempt generates fine """ safe_package = doubles.SafePackageStub(SAMPLE_PACKAGE, '/tmp/') self.assertIsInstance(checkin.get_attempt(safe_package), models.Attempt)
def test_get_attempt_invalid_package_missing_issn_and_article_title(self): """ Package is invalid because there is no ISSN and article_title """ pkg = self._make_test_archive([('texto.xml', b'<root/>')]) safe_package = package.SafePackage(pkg.name, '/tmp/') self.assertRaises(ValueError, lambda: checkin.get_attempt(safe_package))
def test_accessing_generated_attempt_data(self): """ Attempt generates fine """ safe_package = doubles.SafePackageStub(SAMPLE_PACKAGE, '/tmp/') attempt = checkin.get_attempt(safe_package) # this filepath was got from doubles.PackageAnalyzerStub self.assertTrue('/tmp/bla.zip' in attempt.filepath)
def test_get_attempt_article_title_is_already_registered(self): """ There are more than one article registered with same article title """ pkg = checkin.PackageAnalyzer('samples/0042-9686-bwho-91-08-545.zip') article = models.ArticlePkg(**pkg.meta) self.session.add(article) transaction.commit() article2 = models.ArticlePkg(**pkg.meta) article2.journal_title = 'REV' self.session.add(article2) transaction.commit() attempt = checkin.get_attempt('samples/0042-9686-bwho-91-08-545.zip') self.assertIsInstance(attempt, models.Attempt)
def test_get_attempt_article_title_is_already_registered(self): """ There are more than one article registered with same article title """ pkg = package.PackageAnalyzer(SAMPLE_PACKAGE) article = models.ArticlePkg(**pkg.meta) self.session.add(article) transaction.commit() article2 = models.ArticlePkg(**pkg.meta) article2.journal_title = 'REV' self.session.add(article2) transaction.commit() safe_package = doubles.SafePackageStub(SAMPLE_PACKAGE, '/tmp/') attempt = checkin.get_attempt(safe_package) self.assertIsInstance(attempt, models.Attempt)
def test_get_attempt_invalid_package_missing_issn_and_article_title(self): """ Package is invalid because there is no ISSN and article_title """ pkg = self._make_test_archive([('texto.xml', b'<root/>')]) self.assertRaises(ValueError, lambda: checkin.get_attempt(pkg.name))
def test_accessing_generated_attempt_data(self): """ Attempt generates fine """ attempt = checkin.get_attempt('samples/0042-9686-bwho-91-08-545.zip') self.assertTrue('0042-9686-bwho-91-08-545.zip' in attempt.filepath)
def test_get_attempt_ok(self): """ Attempt generates fine """ self.assertIsInstance(checkin.get_attempt('samples/0042-9686-bwho-91-08-545.zip'), models.Attempt)