def test_generated_key_is_unique(self): self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry)) c = self.repo.unique_citekey('Doe2013') self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry, citekey='Doe2013a')) c = self.repo.unique_citekey('Doe2013') self.assertEqual(c, 'Doe2013b')
def test_pushes_paper_metadata(self): orig = {'docfile': 'dummy', 'tags': set(['tag', 'another']), 'added': datetime(2012, 12, 12, 12, 12, 12, 12)} self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry, metadata=orig)) retrieved = self.repo.databroker.pull_metadata('Doe2013') self.assertEqual(orig, retrieved)
def test_pushes_paper_metadata_set_added(self): orig = {'docfile': 'dummy', 'tags': set(['tag', 'another'])} now = datetime.now() self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry, metadata=orig)) retrieved = self.repo.databroker.pull_metadata('Doe2013') self.assertIn('added', retrieved) self.assertTrue(now < retrieved['added'])
def test_pushes_paper_metadata_set_added(self): orig = {'docfile': 'dummy', 'tags': set(['tag', 'another'])} now = datetime.now() self.repo.push_paper( Paper.from_bibentry(fixtures.doe_bibentry, metadata=orig)) retrieved = self.repo.databroker.pull_metadata('Doe2013') self.assertIn('added', retrieved) self.assertTrue(now < retrieved['added'])
def test_pushes_paper_bibdata(self): orig = fixtures.doe_bibentry self.repo.push_paper(Paper.from_bibentry(orig)) retrieved = self.repo.databroker.pull_bibentry('Doe2013') self.assertEqual(orig, retrieved)
def test_raises_value_error_on_existing_key(self): with self.assertRaises(CiteKeyCollision): self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
def test_latex_converted(self): bib = EnDecoder().decode_bibdata(str_fixtures.bibtex_with_latex) p = Paper.from_bibentry(bib) ubib = p.get_unicode_bibdata() self.assertEqual(ubib['author'][0], u"Kjær, Kurt H") self.assertEqual(ubib['author'][3], u"Bjørk, Anders A")
def test_fails_with_empty_citekey(self): with self.assertRaises(ValueError): Paper(" ", fixtures.doe_bibdata)
def setUp(self): super(TestRepo, self).setUp() default_conf = config.load_default_conf() self.repo = Repository(default_conf, create=True) self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
def setUp(self): self.p = Paper.from_bibentry( fixtures.page_bibentry, metadata=fixtures.page_metadata).deepcopy()
def setUp(self): super(TestRepo, self).setUp() self.repo = Repository(configs.Config(), create=True) self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
import unittest import dotdot from pubs.commands.list_cmd import (_check_author_match, _check_field_match, _check_query_block, filter_paper, InvalidQuery) from pubs.paper import Paper import fixtures doe_paper = Paper.from_bibentry(fixtures.doe_bibentry) page_paper = Paper.from_bibentry(fixtures.page_bibentry) turing_paper = Paper.from_bibentry(fixtures.turing_bibentry, metadata=fixtures.turing_metadata) class TestAuthorFilter(unittest.TestCase): def test_fails_if_no_author(self): no_doe = doe_paper.deepcopy() no_doe.bibentry['author'] = [] self.assertTrue(not _check_author_match(no_doe, 'whatever')) def test_match_case(self): self.assertTrue(_check_author_match(doe_paper, 'doe')) self.assertTrue(_check_author_match(doe_paper, 'doe', case_sensitive=False)) def test_do_not_match_case(self):
def test_no_latex(self): p = Paper.from_bibentry(fixtures.page_bibentry, metadata=fixtures.page_metadata).deepcopy() self.assertEqual(p.bibdata, p.get_unicode_bibdata())
import unittest import dotdot from pubs.commands.list_cmd import (_check_author_match, _check_field_match, _check_query_block, filter_paper, InvalidQuery) from pubs.paper import Paper import fixtures doe_paper = Paper.from_bibentry(fixtures.doe_bibentry) page_paper = Paper.from_bibentry(fixtures.page_bibentry) turing_paper = Paper.from_bibentry(fixtures.turing_bibentry, metadata=fixtures.turing_metadata) class TestAuthorFilter(unittest.TestCase): def test_fails_if_no_author(self): no_doe = doe_paper.deepcopy() no_doe.bibentry['author'] = [] self.assertTrue(not _check_author_match(no_doe, 'whatever')) def test_match_case(self): self.assertTrue(_check_author_match(doe_paper, 'doe')) self.assertTrue( _check_author_match(doe_paper, 'doe', case_sensitive=False)) def test_do_not_match_case(self): self.assertFalse(_check_author_match(doe_paper, 'dOe')) self.assertFalse(