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)
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)
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)
def test_extra_keys_empty(self): """Test verifies that by default extra_keys return empty list.""" mb = models.ModelBase() self.assertEqual(mb._extra_keys, [])
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])
def test_modelbase_set(self): mb = models.ModelBase() mb['world'] = 'hello' self.assertEqual(mb['world'], 'hello')
def setUp(self): super(ModelBaseTest, self).setUp() self.mb = models.ModelBase() self.ekm = ExtraKeysModel()