aboutsummaryrefslogtreecommitdiff
path: root/tests/24_test_gbp_import_orig.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/24_test_gbp_import_orig.py')
-rw-r--r--tests/24_test_gbp_import_orig.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py
index 93b656b..4ec5847 100644
--- a/tests/24_test_gbp_import_orig.py
+++ b/tests/24_test_gbp_import_orig.py
@@ -1,7 +1,11 @@
# vim: set fileencoding=utf-8 :
"""Test L{gbp.command_wrappers.Command}'s tarball unpack"""
+import os
+import unittest
+
from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError)
+from gbp.scripts.common.import_orig import download_orig
from . testutils import DebianGitTestRepo
@@ -29,3 +33,22 @@ class TestImportOrigGitRepository(DebianGitTestRepo):
def test_rrr_unknown_action(self):
with self.assertRaisesRegexp(GbpError, "Unknown action unknown for tag doesnotmatter"):
self.repo.rrr('doesnotmatter', 'unknown', 'tag')
+
+
+@unittest.skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
+class TestImportOrigDownload(DebianGitTestRepo):
+ HOST = 'git.sigxcpu.org'
+
+ def setUp(self):
+ DebianGitTestRepo.setUp(self, ImportOrigDebianGitRepository)
+ os.chdir(self.repodir)
+
+ def test_404_download(self):
+ with self.assertRaisesRegexp(GbpError, "404 Client Error: Not Found for url"):
+ download_orig("https://{host}/does_not_exist".format(host=self.HOST))
+
+ def test_200_download(self):
+ pkg = 'hello-debhelper_2.6.orig.tar.gz'
+ url = "https://{host}/cgit/gbp/deb-testdata/tree/dsc-3.0/{pkg}".format(host=self.HOST,
+ pkg=pkg)
+ self.assertEqual(download_orig(url).path, '../%s' % pkg)