def setUp(self): """Set up unit test.""" super(TestCSVReader, self).setUp() with open(join_data_path('csv_ingestion.csv')) as fileobj: self.iterator = data_ingestion.CSVReader(fileobj, 'url', site=self.get_site()) self.obj = next(self.iterator)
def setUp(self): """Set up unit test.""" super(TestCSVReader, self).setUp() with open(join_data_path('csv_ingestion.csv')) as fileobj: self.iterator = data_ingestion.CSVReader(fileobj, 'url', site=self.get_site()) self.obj = next(self.iterator)
def test_lines(self): filename = join_data_path('pagelist-lines.txt') site = self.get_site() titles = list(pagegenerators.TextfilePageGenerator(filename, site)) self.assertEqual(len(titles), len(self.expected_titles)) expected_titles = [ expected_title[self.title_columns[site.namespaces[page.namespace()].case]] for expected_title, page in zip(self.expected_titles, titles)] self.assertPageTitlesEqual(titles, expected_titles)
def test_lines(self): """Test TextfilePageGenerator with newlines.""" filename = join_data_path('pagelist-lines.txt') site = self.get_site() titles = list(pagegenerators.TextfilePageGenerator(filename, site)) self.assertEqual(len(titles), len(self.expected_titles)) expected_titles = [ expected_title[self.title_columns[site.namespaces[page.namespace()].case]] for expected_title, page in zip(self.expected_titles, titles)]
def test_pageTextPost(self): """Test scripts.imagecopy.pageTextPost() method.""" parameters_dict = { 'language': b'id', 'image': b'Ahmad Syaikhu Wakil Walikota Bekasi.jpg', 'newname': b'Ahmad Syaikhu Wakil Walikota Bekasi.jpg', 'project': b'wikipedia', 'username': '', 'commonsense': '1', 'remove_categories': '1', 'ignorewarnings': '1', 'doit': 'Uitvoeren'} commons_helper = pageTextPost('', parameters_dict) # Extract the CommonsHelper description from the html commons_helper = ( re.compile( "<textarea .+ name='wpUploadDescription'>(.+)</textarea>", re.DOTALL | re.M).findall(commons_helper)[0]) with open(join_data_path('commonsHelper_description.txt')) as f: self.assertEqual(f.read(), commons_helper)
def test_pageTextPost(self): """Test scripts.imagecopy.pageTextPost() method.""" parameters_dict = { 'language': b'id', 'image': b'Ahmad Syaikhu Wakil Walikota Bekasi.jpg', 'newname': b'Ahmad Syaikhu Wakil Walikota Bekasi.jpg', 'project': b'wikipedia', 'username': '', 'commonsense': '1', 'remove_categories': '1', 'ignorewarnings': '1', 'doit': 'Uitvoeren'} commons_helper = pageTextPost('', parameters_dict) # Extract the CommonsHelper description from the html commons_helper = ( re.compile( "<textarea .+ name='wpUploadDescription'>(.+)</textarea>", re.DOTALL | re.M).findall(commons_helper)[0]) with open(join_data_path('commonsHelper_description.txt')) as f: self.assertEqual(f.read(), commons_helper)
__version__ = '$Id: 4bbcb74e9a1f82de1694559475fe5b264244b700 $' import pywikibot from pywikibot import fixes from scripts import replace from tests import join_data_path from tests.aspects import unittest from tests.bot_tests import TWNBotTestCase # Load only the custom fixes fixes.fixes.clear() fixes._load_file(join_data_path('fixes.py')) class TestReplacementsMain(TWNBotTestCase): """Test various calls of main().""" SUMMARY_CONFIRMATION = ( 'Press Enter to use this automatic message, or enter a ' 'description of the\nchanges your bot will make:') family = 'test' code = 'test' cached = False def setUp(self): """Replace the original bot class with a fake one."""
def test_update_value(self): """Test loading a fix file changing the fixes.""" fixes.fixes = {} old_fixes = fixes.fixes fixes._load_file(join_data_path('fixes.py')) self.assertIs(fixes.fixes, old_fixes)
def test_overwrite_value(self): """Test loading a fix file overwriting the fixes.""" fixes.fixes = {} old_fixes = fixes.fixes fixes._load_file(join_data_path('set-fixes.py')) self.assertIsNot(fixes.fixes, old_fixes)
def test_update_value(self): """Test loading a fix file changing the fixes.""" fixes.fixes = {} old_fixes = fixes.fixes fixes._load_file(join_data_path('fixes.py')) self.assertIs(fixes.fixes, old_fixes)
def test_overwrite_value(self): """Test loading a fix file overwriting the fixes.""" fixes.fixes = {} old_fixes = fixes.fixes fixes._load_file(join_data_path('set-fixes.py')) self.assertIsNot(fixes.fixes, old_fixes)
__version__ = '$Id: e06247703711c2912e8ff00835dcc212ff762557 $' import pywikibot from pywikibot import fixes from scripts import replace from tests import join_data_path from tests.aspects import unittest from tests.bot_tests import TWNBotTestCase # Load only the custom fixes fixes.fixes.clear() fixes._load_file(join_data_path('fixes.py')) class TestReplacementsMain(TWNBotTestCase): """Test various calls of main().""" SUMMARY_CONFIRMATION = ( 'Press Enter to use this automatic message, or enter a ' 'description of the\nchanges your bot will make:') family = 'test' code = 'test' cached = False def setUp(self):
__version__ = "$Id: e7181e702f3cf015bd0f35750614afc01a6b1730 $" import pywikibot from pywikibot import fixes from scripts import replace from tests import join_data_path from tests.aspects import unittest from tests.bot_tests import TWNBotTestCase # Load only the custom fixes fixes.fixes.clear() fixes._load_file(join_data_path("fixes.py")) class TestReplacementsMain(TWNBotTestCase): """Test various calls of main().""" SUMMARY_CONFIRMATION = ( "Press Enter to use this automatic message, or enter a " "description of the\nchanges your bot will make:" ) family = "test" code = "test" cached = False def setUp(self):