def test_eq(self): delve1 = JsonDelver(self.file1.name) delve2 = JsonDelver(self.file2.name) delve3 = DataDelver(delve1.get('').copy()) linked = ChainedDelver(delve1, delve2) notequal = ChainedDelver(delve2, delve1) equal = ChainedDelver(delve3, delve2) self.assertNotEqual(linked, notequal) self.assertEqual(linked, equal)
def test_flyweight_redundant_init(self): first = JsonDelver(self.file.name) first.set('/new', 'something') second = JsonDelver(self.file.name) self.assertEqual(second.get('/new'), 'something') self.assertIs(first, second)
def test_default(self): delve = JsonDelver(self.file.name) sentinel = object() self.assertIs(delve.get('/nonexistent', sentinel), sentinel)
def test_init(self): delve = JsonDelver(self.file.name) self.assertEqual(delve.get(''), self.data)