def test_Record(self): from clld.lib.bibtex import Record, EntryType rec = Record('article', '1', author=['a', 'b'], editor='a and b') self.assertEqual(rec['author'], 'a and b') self.assertEqual(rec.get('author'), rec.getall('author')) self.assertEqual(rec['editor'], rec.get('editor')) self.assertEqual(rec.getall('editor'), ['a', 'b']) rec = Record('book', '1', title='The Title', author='author', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M', note="Revised edition") self.assertIn('@book', rec.__unicode__()) self.assertIn('@book', rec.__str__()) self.assertIn('bt', rec.text()) for fmt in ['txt', 'en', 'ris', 'mods']: rec.format(fmt) Record.from_string(rec.__unicode__(), lowercase=True) Record.from_object(Mock()) rec = Record('incollection', '1', title='The Title', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M', note="Revised edition") self.assertIn('In ', rec.text()) rec = Record('article', '1', title='The Title', journal='The Journal', volume="The volume", issue='issue') self.assertTrue('The Journal' in rec.text()) rec = Record('xmisc', '1', note='Something') self.assertEqual(rec.genre, EntryType.misc) self.assertIn('Something', rec.text())
def test_Record(self): from clld.lib.bibtex import Record, EntryType rec = Record('article', '1', author=['a', 'b'], editor='a and b') self.assertEqual(rec['author'], 'a and b') self.assertEqual(rec.get('author'), rec.getall('author')) self.assertEqual(rec['editor'], rec.get('editor')) self.assertEqual(rec.getall('editor'), ['a', 'b']) rec = Record( 'book', '1', title='The Title', author='author', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M', note="Revised edition") self.assertIn('@book', rec.__unicode__()) self.assertIn('@book', rec.__str__()) self.assertIn('bt', rec.text()) for fmt in ['txt', 'en', 'ris', 'mods']: rec.format(fmt) Record.from_string(rec.__unicode__(), lowercase=True) Record.from_object(Mock()) rec = Record( 'incollection', '1', title='The Title', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M', note="Revised edition") self.assertIn('In ', rec.text()) rec = Record( 'article', '1', title='The Title', journal='The Journal', volume="The volume", issue='issue') self.assertTrue('The Journal' in rec.text()) rec = Record('xmisc', '1', note='Something') self.assertEqual(rec.genre, EntryType.misc) self.assertIn('Something', rec.text())
def test_Record(self): from clld.lib.bibtex import Record rec = Record( 'book', '1', title='The Title', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M') self.assertTrue('@book' in rec.__unicode__()) self.assertTrue('@book' in rec.__str__()) self.assertTrue('The Title' in rec.text()) for fmt in ['txt', 'en', 'ris', 'mods']: rec.format(fmt) rec = Record.from_string(rec.__unicode__()) rec = Record.from_object(Mock())
def test_Record(self): from clld.lib.bibtex import Record rec = Record('book', '1', title='The Title', editor='ed', booktitle='bt', school='s', issue='i', pages='1-4', publisher='M') self.assertTrue('@book' in rec.__unicode__()) self.assertTrue('@book' in rec.__str__()) self.assertTrue('The Title' in rec.text()) for fmt in ['txt', 'en', 'ris', 'mods']: rec.format(fmt) rec = Record.from_string(rec.__unicode__()) rec = Record.from_object(Mock())