def test_friends_first_name(self): friends = xpath_json.extract('friends/#/firstName', self.input) first_names = ['Dale', 'Roger', 'Jane'] self.assertListEqual(friends, first_names)
def test_fav_movie(self): fav_movie = xpath_json.extract('fav.movie', self.input) self.assertEqual(fav_movie, 'Mr & Mrs Smith')
def test_friends_age_lt_47(self): friends = xpath_json.extract('friends/#[age<47]/#', self.input) self.assertEqual(friends, 1)
def test_home_phone_number(self): phone_number = xpath_json.extract( 'phoneNumbers/#[description==mobile]/0/number', self.input) self.assertEqual(phone_number, '678-555-1234')
def test_find_address_by_zipcode(self): addresses = xpath_json.extract('addresses/#[postalCode==30305]/#', self.input) self.assertEqual(addresses, 2)
def test_home_address(self): address = xpath_json.extract('addresses/#[description==home]', self.input) self.assertDictEqual(address[0], self.input['addresses'][0])
def test_count_addresses(self): count = xpath_json.extract('addresses/#', self.input) self.assertEqual(count, 2)
def test_spouse(self): spouse = xpath_json.extract('spouse/firstName', self.input) self.assertEqual(spouse, 'Mary')