Пример #1
0
    def setUp(self):
        self.working_dir = tempfile.mkdtemp(prefix='downloader-tests')
        self.repo = Repository('test-repo', working_dir=self.working_dir)

        self.config = PluginCallConfiguration({}, {})

        self.mock_cancelled_callback = mock.MagicMock().is_cancelled
        self.mock_cancelled_callback.return_value = False

        self.mock_progress_report = mock.MagicMock()

        self.dist = samples.get_valid_repo()
        self.pkg = model.Package(**samples.get_data('package'))
Пример #2
0
from pulp_deb.common import constants, model, samples, utils


# -- test cases ---------------------------------------------------------------


def get_expected(data):
    newdata = {}
    for k, v in data.copy().items():
        if k in constants.PACKAGE_KEYS:
            newdata[k.lower()] = v
    return newdata


PACKAGE = get_expected(samples.get_data("package"))
DATA = samples.DATA


class UtilTests(unittest.TestCase):
    def test_cls_from_package_dict(self):
        cls = model.get_deb822_cls(PACKAGE)
        self.assertEqual(cls, Packages)

    def test_cls_from_resource(self):
        data = [("packages", Packages), ("sources", Sources)]
        for cls_type, cls_expected in data:
            resource = {"type": cls_type}
            cls = model.get_deb822_cls(resource)
            self.assertEqual(cls_expected, cls)