def test_extracted_key_present(self): fake_name = 'hank_williams' data = { 'users': fake_name, } actual_output = utils.extract_value(data, 'users') self.assertEqual(fake_name, actual_output)
def test_extracted_nested_key_value(self): data = { 'users': {'first_name': 'hank', 'surname': 'williams'}, } expected_output = 'hank' actual_output = utils.extract_value(data, 'users.first_name') self.assertEqual(expected_output, actual_output)
def test_extracted_key_absent(self): fake_name = 'hank_williams' data = { 'users': fake_name, } expected_output = 'null' actual_output = utils.extract_value(data, 'wat') self.assertEqual(expected_output, actual_output)
def test_extracted_nested_key_value(self): data = { 'users': { 'first_name': 'hank', 'surname': 'williams' }, } expected_output = 'hank' actual_output = utils.extract_value(data, 'users.first_name') self.assertEqual(expected_output, actual_output)