def test_to_dict_sequence(self): row = ('fred', 'barney') result = dbkit.to_dict(1, [row]) self.assertEqual(len(result), 1) self.assertTrue('barney' in result) self.assertTrue(result['barney'] is row)
def test_to_dict_bad_key(self): try: dbkit.to_dict('foo', [{'bar': 'fred', 'baz': 'barney'}]) self.fail('Expected KeyError') except KeyError: pass
def test_to_dict_happy_path(self): row = {'bar': 'fred', 'baz': 'barney'} result = dbkit.to_dict('baz', [row]) self.assertEqual(len(result), 1) self.assertTrue('barney' in result) self.assertTrue(result['barney'] is row)
def test_to_dict_nothing(self): result = dbkit.to_dict('foo', []) self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_to_dict_sequence(): row = ('fred', 'barney') result = dbkit.to_dict(1, [row]) assert len(result) == 1 assert 'barney' in result assert result['barney'] is row
def test_to_dict_happy_path(): row = {'bar': 'fred', 'baz': 'barney'} result = dbkit.to_dict('baz', [row]) assert len(result) == 1 assert 'barney' in result assert result['barney'] is row
def test_to_dict_bad_key(): try: dbkit.to_dict('foo', [{'bar': 'fred', 'baz': 'barney'}]) assert False, 'Expected KeyError' except KeyError: pass
def test_to_dict_nothing(): result = dbkit.to_dict('foo', []) assert isinstance(result, dict) and len(result) == 0