def test_group_basis_combine_new_group(self): # New groups are added basis = { 'group1': { 'n_objects_used': 5, 'n_objects_discarded': 8 } } new_group = { 'group2': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } target = { 'group1': { 'n_objects_used': 5, 'n_objects_discarded': 8 }, 'group2': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } _combine_benefit_basis(basis, new_group) self.assertEqual(basis, target)
def test_group_basis_combine_existing_groups(self): basis = {'group1': {'n_objects_used': 5, 'n_objects_discarded': 8}} update_group = { 'group1': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } target = {'group1': {'n_objects_used': 18, 'n_objects_discarded': 12}} _combine_benefit_basis(basis, update_group) self.assertEqual(basis, target)
def test_group_basis_empty(self): basis = {} example = { 'group1': { 'n_objects_used': 5, 'n_objects_discarded': 8 }, 'group2': { 'n_objects_used': 10, 'n_objects_discarded': 12 } } _combine_benefit_basis(basis, example) self.assertEqual(basis, example)
def test_group_basis_combine_new_group(self): # New groups are added basis = {'group1': {'n_objects_used': 5, 'n_objects_discarded': 8}} new_group = { 'group2': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } target = { 'group1': { 'n_objects_used': 5, 'n_objects_discarded': 8 }, 'group2': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } _combine_benefit_basis(basis, new_group) self.assertEqual(basis, target)
def test_group_basis_combine_existing_groups(self): basis = { 'group1': { 'n_objects_used': 5, 'n_objects_discarded': 8 } } update_group = { 'group1': { 'n_objects_used': 13, 'n_objects_discarded': 4 } } target = { 'group1': { 'n_objects_used': 18, 'n_objects_discarded': 12 } } _combine_benefit_basis(basis, update_group) self.assertEqual(basis, target)