예제 #1
0
    def test_unsupported(self):
        # Test
        report = upload.upload(None, "foo", self.unit_key, self.metadata, self.file_path, self.conduit, self.config)

        # Verify
        self.assertTrue(report is not None)
        self.assertFalse(report["success_flag"])
        self.assertTrue("errors" in report["details"])
        self.assertTrue("foo" in report["details"]["errors"][0])
예제 #2
0
    def test_unsupported(self):
        # Test
        report = upload.upload(None, 'foo', self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        self.assertTrue(report is not None)
        self.assertFalse(report['success_flag'])
        self.assertTrue('errors' in report['details'])
        self.assertTrue('foo' in report['details']['errors'][0])
예제 #3
0
    def test_srpm(self, mock_handle):
        # Test
        report = upload.upload(None, models.SRPM.TYPE, self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        mock_handle.assert_called_once_with(None, models.SRPM.TYPE, self.unit_key, self.metadata,
                                            self.file_path, self.conduit, self.config)

        self.assertTrue(report is not None)
        self.assertTrue(report['success_flag'])
예제 #4
0
    def test_store_file_error(self, mock_handle):
        # Setup
        mock_handle.side_effect = upload.StoreFileError()

        # Test
        report = upload.upload(None, models.RPM.TYPE, self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        self.assertFalse(report['success_flag'])
        self.assertTrue('errors' in report['details'])
        self.assertTrue('storage' in report['details']['errors'][0])
예제 #5
0
    def test_unexpected(self, mock_handle):
        # Setup
        mock_handle.side_effect = Exception()

        # Test
        report = upload.upload(None, models.RPM.TYPE, self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        self.assertFalse(report['success_flag'])
        self.assertTrue('errors' in report['details'])
        self.assertTrue('unexpected' in report['details']['errors'][0])
예제 #6
0
    def test_drpm(self, mock_handle):
        """Test if upload function choose correct function to handle DRPM."""
        # Test
        report = upload.upload(None, models.DRPM.TYPE, self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        mock_handle.assert_called_once_with(None, models.DRPM.TYPE, self.unit_key, self.metadata,
                                            self.file_path, self.conduit, self.config)

        self.assertTrue(report is not None)
        self.assertTrue(report['success_flag'])
예제 #7
0
    def test_model_instantiation_error(self, mock_handle):
        # Setup
        mock_handle.side_effect = upload.ModelInstantiationError()

        # Test
        report = upload.upload(None, models.RPM.TYPE, self.unit_key, self.metadata,
                               self.file_path, self.conduit, self.config)

        # Verify
        self.assertTrue(not report['success_flag'])
        self.assertTrue('errors' in report['details'])
        self.assertTrue('invalid' in report['details']['errors'][0])
예제 #8
0
    def test_category(self, mock_handle):
        # Test
        report = upload.upload(
            None, models.PackageCategory.TYPE, self.unit_key, self.metadata, self.file_path, self.conduit, self.config
        )

        # Verify
        mock_handle.assert_called_once_with(
            models.PackageCategory.TYPE, self.unit_key, self.metadata, self.file_path, self.conduit, self.config
        )

        self.assertTrue(report is not None)
        self.assertTrue(report["success_flag"])
예제 #9
0
    def test_package_metadata_error(self, mock_handle):
        # Setup
        mock_handle.side_effect = upload.PackageMetadataError()

        # Test
        report = upload.upload(
            None, models.RPM.TYPE, self.unit_key, self.metadata, self.file_path, self.conduit, self.config
        )

        # Verify
        self.assertFalse(report["success_flag"])
        self.assertTrue("errors" in report["details"])
        self.assertTrue("extracted" in report["details"]["errors"][0])
예제 #10
0
    def test_upload(self):
        self.conduit.init_unit = mock.MagicMock(spec_set=self.conduit.init_unit)
        self.conduit.save_unit = mock.MagicMock(spec_set=self.conduit.save_unit)
        unit_key = {'id': 'group1', 'repo_id': self.repo.id}

        report = upload.upload(self.repo, models.PackageGroup.TYPE, unit_key,
                               self.metadata, '', self.conduit,
                               PluginCallConfiguration({}, {}))

        self.conduit.init_unit.assert_called_once_with(models.PackageGroup.TYPE,
                                                       unit_key, self.metadata, '')
        self.conduit.save_unit.assert_called_once_with(self.conduit.init_unit.return_value)
        self.assertTrue(isinstance(report, dict))
        self.assertEqual(report['success_flag'], True)
예제 #11
0
    def test_group(self, mock_handle):
        # Test
        report = upload.upload(None, models.PackageGroup.TYPE, self.unit_key,
                               self.metadata, self.file_path, self.conduit,
                               self.config)

        # Verify
        mock_handle.assert_called_once_with(None, models.PackageGroup.TYPE,
                                            self.unit_key, self.metadata,
                                            self.file_path, self.conduit,
                                            self.config)

        self.assertTrue(report is not None)
        self.assertTrue(report['success_flag'])
예제 #12
0
    def test_drpm(self, mock_handle):
        """Test if upload function choose correct function to handle DRPM."""
        # Test
        report = upload.upload(None, models.DRPM.TYPE, self.unit_key,
                               self.metadata, self.file_path, self.conduit,
                               self.config)

        # Verify
        mock_handle.assert_called_once_with(None, models.DRPM.TYPE,
                                            self.unit_key, self.metadata,
                                            self.file_path, self.conduit,
                                            self.config)

        self.assertTrue(report is not None)
        self.assertTrue(report['success_flag'])
예제 #13
0
    def test_location_in_repodata(self, mock_copy, mock_get_xml):
        """This is in response to BZ 993452"""
        mock_get_xml.side_effect = self.wrap_get_package_xml
        unit = Unit(self.model.TYPE, self.model.unit_key, self.model.metadata,
                    self.model.relative_path)
        self.conduit.init_unit = mock.MagicMock(spec_set=self.conduit.init_unit,
                                                return_value=unit)
        self.conduit.save_unit = mock.MagicMock(spec_set=self.conduit.save_unit)

        report = upload.upload(self.repo, models.RPM.TYPE, self.model.unit_key,
                               self.model.metadata, self.file_path, self.conduit, {})

        self.assertEqual(report['success_flag'], True)
        # now make sure the correct location tag exists
        saved_unit = self.conduit.save_unit.call_args[0][0]
        primary = saved_unit.metadata['repodata']['primary']
        regex = r'<location href="%s"/>' % os.path.basename(self.file_path)
        self.assertTrue(re.search(regex, primary) is not None)
예제 #14
0
    def test_upload(self, mock_copy, mock_get_xml):
        mock_get_xml.side_effect = self.wrap_get_package_xml
        unit = Unit(self.model.TYPE, self.model.unit_key, self.model.metadata,
                    self.model.relative_path)
        self.conduit.init_unit = mock.MagicMock(spec_set=self.conduit.init_unit,
                                                return_value=unit)
        self.conduit.save_unit = mock.MagicMock(spec_set=self.conduit.save_unit)

        report = upload.upload(self.repo, models.SRPM.TYPE, self.model.unit_key,
                               self.model.metadata, self.file_path, self.conduit, {})

        self.assertEqual(report['success_flag'], True)
        # now make sure the correct location tag exists
        saved_unit = self.conduit.save_unit.call_args[0][0]
        primary = saved_unit.metadata['repodata']['primary']
        regex = r'<location href="%s"/>' % os.path.basename(self.file_path)
        self.assertTrue(re.search(regex, primary) is not None)
        # spot check that the requires were found and put in the right places
        self.assertTrue(primary.find('zlib-devel') >= 0)
        self.assertEqual(len(saved_unit.metadata['requires']), 2)
예제 #15
0
 def upload_unit(self, repo, type_id, unit_key, metadata, file_path, conduit, config):
     return upload.upload(repo, type_id, unit_key, metadata, file_path, conduit, config)
예제 #16
0
 def upload_unit(self, transfer_repo, type_id, unit_key, metadata, file_path, conduit, config):
     repo = transfer_repo.repo_obj
     conduit.repo = repo
     return upload.upload(repo, type_id, unit_key, metadata, file_path, conduit, config)
예제 #17
0
 def upload_unit(self, transfer_repo, type_id, unit_key, metadata, file_path, conduit, config):
     repo = transfer_repo.repo_obj
     conduit.repo = repo
     return upload.upload(repo, type_id, unit_key, metadata, file_path, conduit, config)