def test_extras_len_works_as_expected(self): extras = Extras([]) self.assertEquals(0, extras.len()) extras = Extras({'dates': 'foo', 'bar': 'baz'}) self.assertEquals(2, extras.len()) extras = Extras([ { 'key': 'one', 'value': [1] }, { 'key': 'two', 'value': [2] }, { 'key': 'three', 'value': [3] }, ]) self.assertEquals(3, extras.len())
def test_removes_on_dict_list(self): extras = Extras([ { 'key': 'one', 'value': 1 }, { 'key': 'two', 'value': 2 }, ]) self.assertTrue(extras.remove('two')) self.assertEquals(1, extras.len())
def upsert_on_empty_dict_list_works_as_expected(self): extras = Extras() expected_extras = [{ 'key': 'three', 'value': 3, }] self.assertTrue(extras.update('three', 3, True)) self.assertEquals(3, extras.value('three')) self.assertEquals(1, extras.len()) self.assertEquals(expected_extras, extras.get())
def upsert_on_dict_list_works_as_expected(self): extras = Extras([ { 'key': 'one', 'value': 1 }, { 'key': 'two', 'value': 2 }, ]) self.assertTrue(extras.update('three', 3, True)) self.assertEquals(3, extras.value('three')) self.assertEquals(3, extras.len())
def test_removes_on_flat_list(self): extras = Extras({'dates': 'foo', 'bar': 'baz', 'some': 'thing'}) self.assertTrue(extras.remove('bar')) self.assertEquals(2, extras.len())
def upsert_on_flat_list_works_as_expected(self): extras = Extras({'dates': 'foo', 'bar': 'baz', 'some': 'thing'}) self.assertTrue(extras.update('new', 'kid', True)) self.assertEquals('kid', extras.value('new')) self.assertEquals(4, extras.len())