def test_xml(self): ws = WikiStats() data = ws.get_dict('wikisource', 'xml') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('id', data) self.assertGreater(int(data['fr']['total']), 1600000)
def test_csv(self): if not csv: raise unittest.SkipTest('unicodecsv not installed.') ws = WikiStats() data = ws.get_dict('wikipedia', 'csv') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('ht', data) self.assertGreater(int(data['en']['total']), 4000000) data = ws.get_dict
def test_sorting_order(self): """Test sorting order of languages_by_size.""" family = 'wikipedia' ws = WikiStats() data = ws.get_dict(family) last = sys.maxsize last_code = '' for code in ws.languages_by_size(family): curr = int(data[code]['good']) self.assertGreaterEqual( last, curr, '{} ({}) is greater than {} ({}).'.format( code, curr, last_code, last)) last = curr last_code = code
def test_wikisource(self): """Test WikiStats wikisource data content.""" ws = WikiStats() data = ws.get_dict('wikisource') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('id', data) self.assertGreater(int(data['fr']['total']), int(data['fr']['good'])) data = data['fr'] self.assertTrue(all(isinstance(key, str) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], str) self.assertIn('prefix', data) self.assertIn('total', data)
def test_xml(self): """Test XML.""" ws = WikiStats() data = ws.get_dict('wikisource', 'xml') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('id', data) self.assertGreater(int(data['fr']['total']), int(data['fr']['good'])) data = data['fr'] self.assertTrue(all(isinstance(key, UnicodeType) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], UnicodeType) self.assertIn('prefix', data) self.assertIn('total', data)
def test_sorting_order(self): """Test sorting order of languages_by_size.""" FAMILY = 'wikipedia' ws = WikiStats() data = ws.get_dict(FAMILY) last = sys.maxsize last_code = '' for code in ws.languages_by_size(FAMILY): curr = int(data[code]['good']) self.assertGreaterEqual( last, curr, '{0} ({1}) is greater than {2} ({3}).' ''.format(code, curr, last_code, last)) last = curr last_code = code
def test_xml(self): """Test XML.""" ws = WikiStats() data = ws.get_dict('wikisource', 'xml') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('id', data) self.assertGreater(int(data['fr']['total']), int(data['fr']['good'])) data = data['fr'] self.assertTrue( all( isinstance(key, UnicodeType) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], UnicodeType) self.assertIn('prefix', data) self.assertIn('total', data)
def test_csv(self): """Test CSV.""" ws = WikiStats() data = ws.get_dict('wikipedia', 'csv') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('ht', data) self.assertGreater(int(data['en']['total']), int(data['en']['good'])) data = data['en'] self.assertTrue( all( isinstance(key, str) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], str) self.assertIn('prefix', data) self.assertIn('total', data)
def test_csv(self): """Test CSV.""" if not csv: raise unittest.SkipTest('unicodecsv not installed.') ws = WikiStats() data = ws.get_dict('wikipedia', 'csv') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('ht', data) self.assertGreater(int(data['en']['total']), int(data['en']['good'])) data = data['en'] self.assertTrue(all(isinstance(key, UnicodeType) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], UnicodeType) self.assertIn('prefix', data) self.assertIn('total', data)
def test_csv(self): """Test CSV.""" if not csv: raise unittest.SkipTest('unicodecsv not installed.') ws = WikiStats() data = ws.get_dict('wikipedia', 'csv') self.assertIsInstance(data, dict) self.assertIn('en', data) self.assertIn('ht', data) self.assertGreater(int(data['en']['total']), int(data['en']['good'])) data = data['en'] self.assertTrue( all( isinstance(key, UnicodeType) for key in data.keys() if key is not None)) self.assertIsInstance(data['total'], UnicodeType) self.assertIn('prefix', data) self.assertIn('total', data)