Skip to content

Commit

Permalink
Add UT for toolbox.download_http_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Carel committed Jul 28, 2015
1 parent 03c1a1b commit 2a19707
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import tempfile
import unittest

import requests

from easy_upgrade.toolbox import (
download_http_url,
find_executable,
pushd,
temp_dir,
Expand Down Expand Up @@ -37,3 +40,22 @@ def test_temp_dir(self):
with temp_dir(cleanup=False) as d:
self.assertTrue(osp.isdir(d))
self.assertTrue(osp.isdir(d))

def test_file_download(self):
url = 'http://ovh.net/files/md5sum.txt'
session = requests.Session()
with temp_dir() as d:
file_path, content_type = download_http_url(
url,
session,
d,
filename='foo.txt')
self.assertIsNotNone(file_path)
self.assertEqual(osp.abspath(file_path), file_path)
self.assertIsNotNone(content_type)
self.assertEquals(content_type, 'text/plain')
self.assertTrue(osp.isfile(file_path))


if __name__ == '__main__':
unittest.main()

0 comments on commit 2a19707

Please sign in to comment.