Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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'])
Ejemplo n.º 6
0
 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'])
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def test_raises_value_error_on_existing_key(self):
     with self.assertRaises(CiteKeyCollision):
         self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
Ejemplo n.º 9
0
 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")
Ejemplo n.º 10
0
 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")
Ejemplo n.º 11
0
 def test_fails_with_empty_citekey(self):
     with self.assertRaises(ValueError):
         Paper(" ", fixtures.doe_bibdata)
Ejemplo n.º 12
0
 def test_raises_value_error_on_existing_key(self):
     with self.assertRaises(CiteKeyCollision):
         self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
Ejemplo n.º 13
0
 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))
Ejemplo n.º 14
0
 def setUp(self):
     self.p = Paper.from_bibentry(
         fixtures.page_bibentry,
         metadata=fixtures.page_metadata).deepcopy()
Ejemplo n.º 15
0
 def setUp(self):
     super(TestRepo, self).setUp()
     self.repo = Repository(configs.Config(), create=True)
     self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
Ejemplo n.º 16
0
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):
Ejemplo n.º 17
0
 def setUp(self):
     self.p = Paper.from_bibentry(
         fixtures.page_bibentry,
         metadata=fixtures.page_metadata).deepcopy()
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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())
Ejemplo n.º 20
0
 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))
Ejemplo n.º 21
0
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(
Ejemplo n.º 22
0
 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())