Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def test_default(self):
     delve = JsonDelver(self.file.name)
     sentinel = object()
     self.assertIs(delve.get('/nonexistent', sentinel), sentinel)
Exemplo n.º 4
0
 def test_init(self):
     delve = JsonDelver(self.file.name)
     self.assertEqual(delve.get(''), self.data)