Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_valid_formatted_release_dates(self):
formatted_output = utils.formatted_valid_release_dates()
firefox_releases = utils.releases()
for line in formatted_output.splitlines():
if "Valid releases: " in line:
continue
fields = line.translate(None, " ").split(":")
version = int(fields[0])
date = fields[1]
self.assertTrue(firefox_releases.has_key(version))
self.assertEquals(date, firefox_releases[version])
def test_url_with_links_regex(self, get):
get.return_value = Mock(text="""
<a href="thing/">thing</a>
<a href="thing2/">thing2</a>
""")
self.assertEquals(
utils.url_links('', regex="thing2.*"),
['thing2/'])
def test_valid_release_to_date(self):
date = utils.date_of_release(8)
self.assertEquals(date, "2011-08-16")
date = utils.date_of_release(15)
self.assertEquals(date, "2012-06-05")
date = utils.date_of_release(34)
self.assertEquals(date, "2014-09-02")
this is a response.
""" * (1024 * 16)
def iter_content(chunk_size=1):
rest = self.data
while rest:
chunk = rest[:chunk_size]
rest = rest[chunk_size:]
yield chunk
response = Mock(headers={'Content-length': str(len(self.data))},
iter_content=iter_content)
get.return_value = response
fname = os.path.join(self.tempdir, 'some.content')
utils.download_url('http://toto', fname)
self.assertEquals(self.data, open(fname).read())
def test_url_no_links(self, get):
get.return_value = Mock(text='')
self.assertEquals(utils.url_links(''), [])
def test_get_http_session(self):
utils.set_http_cache_session(self.make_cache())
a_session = utils.get_http_session()
# verify session exists
self.assertTrue(isinstance(a_session, requests.Session))
# turns out CacheControl is just a function not a class
# so it makes verifying that we're actually using it
# a little messy
for k, v in a_session.adapters.items():
self.assertTrue(isinstance(v.cache, limitedfilecache.LimitedFileCache))
def test_get_app(self):
argv = ['inboundfinder', '--start-rev=1', '--end-rev=2',]
actual = inboundfinder.get_build_finder(argv)
self.assertTrue(isinstance(actual, inboundfinder.BuildsFinder))
# default is to use a cache session
a_session = utils.get_http_session()
self.assertTrue(isinstance(a_session, requests.Session))