def test_update_with_a_dictionary(self): container = DataContainer() data = {key: 3 for key in CUBA} container.update(data) self.assertEqual(container, data) for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_a_dictionary(self): container = DataContainer() data = {key: 3 for key in CUBA} container.update(data) self.assertEqual(container, data) for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_keywords(self): container = DataContainer() data = {key: index + 3 for index, key in enumerate(CUBA.__members__)} container.update(**data) self.assertEqual( container, {key: index + 3 for index, key in enumerate(CUBA)}) for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_a_iterable(self): container = DataContainer() data = [(key, 3) for key in CUBA] container.update(data) # Check that has all the values for key, value in data: self.assertEqual(container[key], value) self.assertIsInstance(key, CUBA)
def test_update_with_a_iterable(self): container = DataContainer() data = [(key, 3) for key in CUBA] container.update(data) # Check that has all the values for key, value in data: self.assertEqual(container[key], value) self.assertIsInstance(key, CUBA)
def test_update_with_keywords(self): container = DataContainer() data = {key: index + 3 for index, key in enumerate(CUBA.__members__)} container.update(**data) self.assertEqual(container, {key: index + 3 for index, key in enumerate(CUBA)}) for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_keywords_and_iterable(self): container = DataContainer() data = { key: 3 for index, key in enumerate(CUBA.__members__) if key != str(CUBA("POTENTIAL_ENERGY"))[5:]} container.update([(CUBA("POTENTIAL_ENERGY"), 23)], **data) expected = {key: index + 3 for index, key in enumerate(CUBA)} expected[CUBA("POTENTIAL_ENERGY")] = 23 for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_keywords_and_iterable(self): container = DataContainer() data = { key: index + 3 for index, key in enumerate(CUBA.__members__) if key != str(CUBA(10))[5:]} container.update([(CUBA(10), 23)], **data) expected = {key: index + 3 for index, key in enumerate(CUBA)} expected[CUBA(10)] = 23 self.assertDictEqual(container, expected) for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_keywords_and_iterable(self): container = DataContainer() data = { key: 3 for index, key in enumerate(CUBA.__members__) if key != str(CUBA("POTENTIAL_ENERGY"))[5:] } container.update([(CUBA("POTENTIAL_ENERGY"), 23)], **data) expected = {key: index + 3 for index, key in enumerate(CUBA)} expected[CUBA("POTENTIAL_ENERGY")] = 23 for key in container: self.assertIsInstance(key, CUBA)
def test_update_with_a_dictionary_of_strings(self): container = DataContainer() data = {str(key): 3 for key in CUBA} with self.assertRaises(ValueError): container.update(data)
def test_update_with_non_cuba_kwards(self): container = DataContainer() with self.assertRaises(ValueError): container.update(bar=5)
def test_update_with_non_cuba_iterable(self): container = DataContainer() with self.assertRaises(ValueError): container.update([('foo', 5)])
def test_update_with_non_cuba_dict(self): container = DataContainer() with self.assertRaises(ValueError): container.update({'foo': 5})
def test_update_with_non_cuba_kwards(self): container = DataContainer() with self.assertRaises(ValueError): container.update(bar=5)
def test_update_with_a_dictionary_of_strings(self): container = DataContainer() data = {str(key): 3 for key in CUBA} with self.assertRaises(ValueError): container.update(data)
def test_update_with_non_cuba_dict(self): container = DataContainer() with self.assertRaises(ValueError): container.update({'foo': 5})
def test_update_with_non_cuba_iterable(self): container = DataContainer() with self.assertRaises(ValueError): container.update([('foo', 5)])