def setUp(self): super(TestFTPScraper, self).setUp() self.psycopg2_patcher = mock.patch('psycopg2.connect') self.psycopg2 = self.psycopg2_patcher.start() self.urllib2_patcher = mock.patch('urllib2.urlopen') self.urllib2 = self.urllib2_patcher.start() self.scrapers = ftpscraper.ScrapersMixin() self.scrapers.config = DotDict({'logger': mock.Mock()})
def setUp(self): super(TestFTPScraper, self).setUp() self.psycopg2_patcher = mock.patch('psycopg2.connect') self.psycopg2 = self.psycopg2_patcher.start() self.requests_session_patcher = mock.patch('requests.Session') self.mocked_session = self.requests_session_patcher.start() def download(url): return self.mocked_session.get(url) def skip_json_file(url): if url.endswith('mozinfo.json'): return True return False self.scrapers = ftpscraper.ScrapersMixin() self.scrapers.download = download self.scrapers.skip_json_file = skip_json_file self.scrapers.config = DotDict({'logger': mock.Mock()})
def setUp(self): super(TestIntegrationFTPScraper, self).setUp() cursor = self.conn.cursor() # Insert data now = utc_now() build_date = now - datetime.timedelta(days=30) sunset_date = now + datetime.timedelta(days=30) cursor.execute(""" TRUNCATE products CASCADE; INSERT INTO products (product_name, sort, release_name) VALUES ( 'Firefox', 1, 'firefox' ), ( 'Fennec', 1, 'mobile' ); """) cursor.execute(""" TRUNCATE product_versions CASCADE; INSERT INTO product_versions (product_version_id, product_name, major_version, release_version, version_string, version_sort, build_date, sunset_date, featured_version, build_type) VALUES ( 1, 'Firefox', '15.0', '15.0', '15.0a1', '000000150a1', '%(build_date)s', '%(sunset_date)s', 't', 'nightly' ) ,( 2, 'Firefox', '24.5', '24.5.0esr', '24.5.0esr', '024005000x000', '%(build_date)s', '%(sunset_date)s', 't', 'esr' ) ; """ % { "build_date": build_date, "sunset_date": sunset_date }) cursor.execute(""" TRUNCATE release_channels CASCADE; INSERT INTO release_channels (release_channel, sort) VALUES ('nightly', 1), ('aurora', 2), ('beta', 3), ('release', 4); """) cursor.execute(""" TRUNCATE product_release_channels CASCADE; INSERT INTO product_release_channels (product_name, release_channel, throttle) VALUES ('Firefox', 'nightly', 1), ('Firefox', 'aurora', 1), ('Firefox', 'beta', 1), ('Firefox', 'release', 1), ('Fennec', 'release', 1), ('Fennec', 'beta', 1); """) self.conn.commit() self.requests_session_patcher = mock.patch('requests.Session') self.mocked_session = self.requests_session_patcher.start() def download(url): return self.mocked_session.get(url) def skip_json_file(url): return False self.scrapers = ftpscraper.ScrapersMixin() self.scrapers.download = download self.scrapers.skip_json_file = skip_json_file self.scrapers.config = DotDict({'logger': mock.Mock()})