def test_byContinent(self): continents = get_continents() for continent in map(lambda continent: continent['code'], continents): countries = Countries.byContinent(continent) self.assertIsInstance(countries, list) for country in countries: self.assertEqual(continent, country['continent'])
def test_GetWithNoParams(self): r = self.testApp.get('/countries/') self.assertEqual(r.status, 200) countries = json.loads(r.body) self.assertListEqual(countries, Countries.find(lambda c: True))
def test_Countries(self): countries = Countries.find(lambda c: True) with_code = [country for country in countries if country['code']] self.assertTrue(len(with_code)/float(len(countries)) > 0.67)