def test_from_document(self): duplicate1 = Duplicate.from_document({ 'duplicate': 'This is a duplicate', 'end': '500', 'file': 'afile', 'start': '300' }) self.assertIsNotNone(duplicate1) self.assertIsNone(duplicate1.id) self.assertEqual('This is a duplicate', duplicate1.duplicate) self.assertEqual('afile', duplicate1.file) self.assertEqual('300', duplicate1.start) self.assertEqual('500', duplicate1.end) duplicate2 = Duplicate.from_document({ '_id': '666', 'duplicate': 'This is a duplicate', 'end': '500', 'file': 'afile', 'start': '300' }) self.assertIsNotNone(duplicate2) self.assertIsNotNone(duplicate2.id) self.assertEqual('666', duplicate2.id) self.assertEqual('This is a duplicate', duplicate1.duplicate) self.assertEqual('afile', duplicate1.file) self.assertEqual('300', duplicate1.start) self.assertEqual('500', duplicate1.end)
def test_from_document_with_no_data(self): duplicate2 = Duplicate.from_document({'_id': '666'}) self.assertIsNotNone(duplicate2) self.assertIsNotNone(duplicate2.id) self.assertEqual('666', duplicate2.id) self.assertIsNone(duplicate2.duplicate) self.assertIsNone(duplicate2.file) self.assertIsNone(duplicate2.start) self.assertIsNone(duplicate2.end)
def test_repr_no_id(self): duplicate1 = Duplicate.from_document({ 'duplicate': 'This is a duplicate', 'end': '500', 'file': 'afile', 'start': '300' }) self.assertEquals( "<Duplicate(id='n/a', duplicate='This is a duplicate', file='afile', start='300', end='500')>", str(duplicate1))