def test_convert_attributes_is_correct_order(self, mock_get_attr): # Arrange mock_get_attr.return_value = ['field1', 'field2', 'field3', 'field4'] attributes = { 'attribute': [ { 'field2': 'value2', 'field3': 'value3', 'field1': 'value1', 'field4': 'value4' } ] } expected_result = { 'attribute': [[ 'value1', 'value2', 'value3', 'value4', ]] } # Act actual_result = db.convert_attributes(attributes) # Assert self.assertEqual(expected_result, actual_result)
def test_convert_attributes_no_value(self, mock_get_attr): # Arrange mock_get_attr.return_value = ['field1', 'field2', 'field3', 'field4'] attributes = {} # Act actual_result = db.convert_attributes(attributes) # Assert self.assertEqual(attributes, actual_result)
def test_convert_attributes_handles_multiple_attributes(self, mock_get_attr): # Arrange mock_get_attr.return_value = ['field1', 'field2', 'field3', 'field4'] attributes = { 'attribute1': [ { 'field2': 'value2' } ], 'attribute2': [ { 'field3': 'value3' } ] } expected_result = { 'attribute1': [[ None, 'value2', None, None, ]], 'attribute2': [[ None, None, 'value3', None, ]] } # Act actual_result = db.convert_attributes(attributes) # Assert self.assertEqual(expected_result, actual_result)
def test_convert_attributes_adds_none_values(self, mock_get_attr): # Arrange mock_get_attr.return_value = ['field1', 'field2', 'field3', 'field4'] attributes = { 'attribute': [ { } ] } expected_result = { 'attribute': [[ None, None, None, None, ]] } # Act actual_result = db.convert_attributes(attributes) # Assert self.assertEqual(expected_result, actual_result)