def test_equals(self): """ the __eq__ method should compare bibcodes, and raise if bibcode isn't defined """ self.assertNotEqual(Article(bibcode="Not the same"), self.article) self.assertEqual(Article(bibcode="2013A&A...552A.143S"), self.article) with self.assertRaises(TypeError): Article() == self.article
def test_equals(self): """ the __eq__ method should compare bibcodes, and raise if bibcode isn't defined or is None """ self.assertNotEqual(Article(bibcode="Not the same"), self.article) self.assertEqual(Article(bibcode="2013A&A...552A.143S"), self.article) with self.assertRaisesRegexp(TypeError, "Cannot compare articles without bibcodes"): Article() == self.article with self.assertRaisesRegexp(TypeError, "Cannot compare articles without bibcodes"): Article(bibcode=None) == self.article
def setUp(self): """ Create a test Article instance """ self.article = Article( bibcode="2013A&A...552A.143S", year=2013, first_author="Sudilovsky, V.", author=[ "Sudilovsky, V", "Greiner, J", "Rau, A", "Salvato, M", "Savaglio, S", "Vergani, S", "Schady, P", "Elliott, J", "Kruehler, T", "Kann, D", "Klose, S", "Rossi, A", "Filgas, R", "Schmidl, S" ], )
def test_print_methods(self): """ the class should return a user-friendly formatted identified when the __str__ or __unicode__ methods are called """ self.assertEqual('<Sudilovsky, V. et al. 2013, 2013A&A...552A.143S>', self.article.__str__()) self.assertEqual(self.article.__unicode__(), self.article.__str__()) self.assertEqual(Article().__str__(), "<Unknown author Unknown year, Unknown bibcode>")