Esempio n. 1
0
 def test_modelbase_iteritems(self):
     self.skipTest("Requires DB")
     mb = models.ModelBase()
     h = {'a': '1', 'b': '2'}
     mb.update(h)
     for key, value in mb.iteritems():
         self.assertEqual(h[key], value)
Esempio n. 2
0
    def test_modelbase_contains(self):
        mb = models.ModelBase()
        h = {'a': '1', 'b': '2'}
        mb.update(h)
        for key in h.keys():
            # Test 'in' syntax (instead of using .assertIn)
            self.assertTrue(key in mb)

        self.assertFalse('non-existent-key' in mb)
Esempio n. 3
0
    def test_modelbase_iter(self):
        self.skipTest("Requires DB")
        mb = models.ModelBase()
        h = {'a': '1', 'b': '2'}
        mb.update(h)
        i = iter(mb)

        min_items = len(h)
        found_items = 0
        while True:
            r = next(i, None)
            if r is None:
                break

            self.assertTrue(r in h)
            found_items += 1

        self.assertEqual(min_items, found_items)
Esempio n. 4
0
 def test_extra_keys_empty(self):
     """Test verifies that by default extra_keys return empty list."""
     mb = models.ModelBase()
     self.assertEqual(mb._extra_keys, [])
Esempio n. 5
0
 def test_modelbase_update(self):
     mb = models.ModelBase()
     h = {'a': '1', 'b': '2'}
     mb.update(h)
     for key in h.keys():
         self.assertEqual(mb[key], h[key])
Esempio n. 6
0
 def test_modelbase_set(self):
     mb = models.ModelBase()
     mb['world'] = 'hello'
     self.assertEqual(mb['world'], 'hello')
Esempio n. 7
0
 def setUp(self):
     super(ModelBaseTest, self).setUp()
     self.mb = models.ModelBase()
     self.ekm = ExtraKeysModel()