summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-10-09 18:50:06 +0100
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-04 12:40:55 +0000
commitd86c76581034b6e1cf7d46b06ddc9440a481cefc (patch)
tree3db7274147b69703e8a20910a0506f6f316c6028
parent516b7ae1a334c4b7175bb59eaab80f2b66d749eb (diff)
downloadimport-d86c76581034b6e1cf7d46b06ddc9440a481cefc.tar.gz
Add basic test for make_tarball_lorry
-rwxr-xr-ximport/pip_lorry_tests.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/import/pip_lorry_tests.py b/import/pip_lorry_tests.py
new file mode 100755
index 0000000..38b8eb3
--- /dev/null
+++ b/import/pip_lorry_tests.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright (C) 2014 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import pip_lorry
+import json
+
+import unittest
+
+class Tests(unittest.TestCase):
+
+ def test_make_tarball_lorry(self):
+ gzip, bzip, lzma = 'gzip', 'bzip2', 'lzma'
+
+ valid_extensions = {'tar.gz': gzip, 'tgz': gzip, 'tar.Z': gzip,
+ 'tar.bz2': bzip, 'tbz2': bzip,
+ 'tar.lzma': lzma, 'tar.xz': lzma,
+ 'tlz': lzma, 'txz': lzma}
+
+ def make_url(extension):
+ return 'http://foobar.baz/%s' % extension
+
+ fake_package_name = 'name'
+ urls = [make_url(extension) for extension in valid_extensions]
+
+ for url in urls:
+ lorry = pip_lorry.make_tarball_lorry('name', url)
+ self.assertEqual(
+ json.loads(lorry)[fake_package_name + '-tarball']['url'], url)
+
+if __name__ == '__main__':
+ suite = unittest.TestLoader().loadTestsFromTestCase(Tests)
+ unittest.TextTestRunner(verbosity=2).run(suite)