Ejemplo n.º 1
0
 def test_unhandled_error(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(
         42, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue("An unexpected error occurred" in cm.exception.msg)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 2
0
 def test_host_unresolvable(self, mock_validate, mock_check_output):
     for err in (5, 6):
         mock_check_output.side_effect = subprocess.CalledProcessError(err, 'mock_cmd')
         with self.assertRaises(exceptions.DownloadException) as cm:
             buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
             self.assertTrue('Unable to resolve the hostname' in cm.exception.msg)
     mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 3
0
 def test_not_http_200(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(
         22, "mock_cmd", output="404")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue("An HTTP error occurred" in cm.exception.msg)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 4
0
 def test_bad_peer_cert(self, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(
         60, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue(
             "Unable to validate the TLS certificate" in cm.exception.msg)
Ejemplo n.º 5
0
 def test_unable_to_connect(self, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(
         7, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue(
             "Unable to connect to the host" in cm.exception.msg)
Ejemplo n.º 6
0
 def test_not_http_200(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(
         22, "mock_cmd", output="404"
     )
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue("An HTTP error occurred" in cm.exception.msg)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 7
0
 def test_host_unresolvable(self, mock_check_output):
     for err in (5, 6):
         mock_check_output.side_effect = subprocess.CalledProcessError(
             err, "mock_cmd")
         with self.assertRaises(exceptions.DownloadException) as cm:
             buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
             self.assertTrue(
                 "Unable to resolve the hostname" in cm.exception.msg)
Ejemplo n.º 8
0
 def test_bad_peer_cert(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(60, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue(
             "Unable to validate the TLS certificate" in cm.exception.msg
         )
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 9
0
 def test_host_unresolvable(self, mock_validate, mock_check_output):
     for err in (5, 6):
         mock_check_output.side_effect = subprocess.CalledProcessError(
             err, "mock_cmd"
         )
         with self.assertRaises(exceptions.DownloadException) as cm:
             buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
             self.assertTrue("Unable to resolve the hostname" in cm.exception.msg)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 10
0
    def test_multiple_sources(self, mock_validate, mock_check_output):
        mock_check_output.return_value = """
Getting https://github.com/org/proj/archive/0.11.0/proj-0.11.0.tar.gz to ./proj-0.11.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   146    0   146    0     0    120      0 --:--:--  0:00:01 --:--:--   120
100   133    0   133    0     0     72      0 --:--:--  0:00:01 --:--:--    72
100 2695k    0 2695k    0     0   211k      0 --:--:--  0:00:12 --:--:--  233k
Getting https://github.com/org/other/archive/1.0/other-1.0.tar.gz to ./other-1.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   147    0   147    0     0    145      0 --:--:--  0:00:01 --:--:--   145
100   133    0   133    0     0    108      0 --:--:--  0:00:01 --:--:--   108
100 2695k  100 2695k    0     0  96565      0  0:00:28  0:00:28 --:--:-- 72941
Getting https://example.com/fix-everything.patch to ./fix-everything.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   148    0   148    0     0     95      0 --:--:--  0:00:01 --:--:--    95
100   133    0   133    0     0     75      0 --:--:--  0:00:01 --:--:--  129k
100 2695k  100 2695k    0     0   135k      0  0:00:19  0:00:19 --:--:-- 84347
"""
        expected_sources = [
            '/tmp/dir/proj-0.11.0.tar.gz',
            '/tmp/dir/other-1.0.tar.gz',
            '/tmp/dir/fix-everything.patch',
        ]
        sources = buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
        self.assertEqual(expected_sources, sources)
        mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 11
0
    def test_multiple_sources(self, mock_validate, mock_check_output):
        mock_check_output.return_value = """
Getting https://github.com/org/proj/archive/0.11.0/proj-0.11.0.tar.gz to ./proj-0.11.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   146    0   146    0     0    120      0 --:--:--  0:00:01 --:--:--   120
100   133    0   133    0     0     72      0 --:--:--  0:00:01 --:--:--    72
100 2695k    0 2695k    0     0   211k      0 --:--:--  0:00:12 --:--:--  233k
Getting https://github.com/org/other/archive/1.0/other-1.0.tar.gz to ./other-1.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   147    0   147    0     0    145      0 --:--:--  0:00:01 --:--:--   145
100   133    0   133    0     0    108      0 --:--:--  0:00:01 --:--:--   108
100 2695k  100 2695k    0     0  96565      0  0:00:28  0:00:28 --:--:-- 72941
Getting https://example.com/fix-everything.patch to ./fix-everything.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   148    0   148    0     0     95      0 --:--:--  0:00:01 --:--:--    95
100   133    0   133    0     0     75      0 --:--:--  0:00:01 --:--:--  129k
100 2695k  100 2695k    0     0   135k      0  0:00:19  0:00:19 --:--:-- 84347
"""
        expected_sources = [
            "/tmp/dir/proj-0.11.0.tar.gz",
            "/tmp/dir/other-1.0.tar.gz",
            "/tmp/dir/fix-everything.patch",
        ]
        sources = buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
        self.assertEqual(expected_sources, sources)
        mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 12
0
 def test_unable_to_connect(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(7, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue("Unable to connect to the host" in cm.exception.msg)
         mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 13
0
 def test_no_sources_spec(self, mock_validate, mock_check_output):
     mock_check_output.return_value = ""
     sources = buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
     self.assertEqual([], sources)
     mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 14
0
 def test_unable_to_connect(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(7, 'mock_cmd')
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
         self.assertTrue('Unable to connect to the host' in cm.exception.msg)
         mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 15
0
 def test_not_http_200(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(22, 'mock_cmd', output='404')
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
         self.assertTrue('An HTTP error occurred' in cm.exception.msg)
     mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 16
0
 def test_unhandled_error(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(42, "mock_cmd")
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
         self.assertTrue("An unexpected error occurred" in cm.exception.msg)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 17
0
 def test_bad_peer_cert(self, mock_validate, mock_check_output):
     mock_check_output.side_effect = subprocess.CalledProcessError(60, 'mock_cmd')
     with self.assertRaises(exceptions.DownloadException) as cm:
         buildsys.spec_sources('/my/specfile.spec', '/tmp/dir/')
         self.assertTrue('Unable to validate the TLS certificate' in cm.exception.msg)
     mock_validate.assert_called_with('/my/specfile.spec')
Ejemplo n.º 18
0
 def test_no_sources_spec(self, mock_validate, mock_check_output):
     mock_check_output.return_value = ""
     sources = buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
     self.assertEqual([], sources)
     mock_validate.assert_called_with("/my/specfile.spec")
Ejemplo n.º 19
0
 def test_no_sources_spec(self, mock_check_output):
     mock_check_output.return_value = b""
     sources = buildsys.spec_sources("/my/specfile.spec", "/tmp/dir/")
     self.assertEqual([], sources)