예제 #1
0
    def test_without_deps(self):
        conduit = mock.MagicMock()
        rpms = model_factory.rpm_units(3)

        associate.copy_rpms(rpms, conduit, False)

        self.assertEqual(conduit.associate_unit.call_count, 3)
        for rpm in rpms:
            conduit.associate_unit.assert_any_call(rpm)
예제 #2
0
    def test_without_deps(self):
        conduit = mock.MagicMock()
        rpms = model_factory.rpm_units(3)

        associate.copy_rpms(rpms, conduit, False)

        self.assertEqual(conduit.associate_unit.call_count, 3)
        for rpm in rpms:
            conduit.associate_unit.assert_any_call(rpm)
예제 #3
0
    def test_with_existing_deps(self, mock_find, mock_get_existing):
        conduit = mock.MagicMock()
        rpms = model_factory.rpm_units(1)
        deps = model_factory.rpm_units(2)
        mock_find.return_value = set(deps)
        mock_get_existing.return_value = deps

        associate.copy_rpms(rpms, conduit, True)

        self.assertEqual(conduit.associate_unit.call_count, 1)
        self.assertEqual(mock_find.call_count, 1)
        self.assertEqual(mock_find.call_args[0][1], set(rpms))
        self.assertEqual(mock_get_existing.call_count, 1)
예제 #4
0
    def test_with_existing_deps(self, mock_find, mock_get_existing):
        conduit = mock.MagicMock()
        rpms = model_factory.rpm_units(1)
        deps = model_factory.rpm_units(2)
        mock_find.return_value = set(deps)
        mock_get_existing.return_value = deps

        associate.copy_rpms(rpms, conduit, True)

        self.assertEqual(conduit.associate_unit.call_count, 1)
        self.assertEqual(mock_find.call_count, 1)
        self.assertEqual(mock_find.call_args[0][1], set(rpms))
        self.assertEqual(mock_get_existing.call_count, 1)
예제 #5
0
    def test_with_existing_deps(self, mock_find, mock_get_existing):
        conduit = mock.MagicMock()
        rpms = model_factory.rpm_units(1)
        deps = model_factory.rpm_models(2)
        dep_units = [Unit(model.TYPE, model.unit_key, model.metadata, '') for model in deps]
        mock_find.return_value = [r.as_named_tuple for r in deps]
        mock_get_existing.return_value = dep_units

        associate.copy_rpms(rpms, conduit, True)

        self.assertEqual(conduit.associate_unit.call_count, 1)
        self.assertEqual(mock_find.call_count, 1)
        self.assertEqual(mock_find.call_args[0][0], set(rpms))
        # called once directly, and once from filter_available_rpms
        self.assertEqual(mock_get_existing.call_count, 2)
예제 #6
0
    def test_with_recursive_deps(self, mock_find, mock_get_existing):
        """
        Test getting dependencies that do not exist in the repository already
        """
        conduit = mock.MagicMock()
        # Create the primary RPMS that we want to copy
        rpms = model_factory.rpm_units(1)

        # Create the recursive dependencies that we want to copy
        deps = model_factory.rpm_units(2)
        mock_find.side_effect = iter([set(deps), set()])

        # The get existing units always assumes there are no units in the target repository
        mock_get_existing.return_value = []
        unit_set = associate.copy_rpms(rpms, conduit, True)

        merged_set = set(deps)
        merged_set.update(rpms)
        self.assertEquals(unit_set, merged_set)
예제 #7
0
    def test_with_recursive_deps(self, mock_find, mock_get_existing):
        """
        Test getting dependencies that do not exist in the repository already
        """
        conduit = mock.MagicMock()
        # Create the primary RPMS that we want to copy
        rpms = model_factory.rpm_units(1)

        # Create the recursive dependencies that we want to copy
        deps = model_factory.rpm_units(2)
        mock_find.side_effect = iter([set(deps), set()])

        # The get existing units always assumes there are no units in the target repository
        mock_get_existing.return_value = []
        unit_set = associate.copy_rpms(rpms, conduit, True)

        merged_set = set(deps)
        merged_set.update(rpms)
        self.assertEquals(unit_set, merged_set)
예제 #8
0
    def test_with_recursive_deps(self, mock_find, mock_get_existing, mock_filter):
        """
        Test getting dependencies that do not exist in the repository already
        """
        conduit = mock.MagicMock()
        # Create the primary RPMS that we want to copy
        rpms = model_factory.rpm_units(1)

        # Create the recursive dependencies that we want to copy
        deps = model_factory.rpm_models(2)
        dep_units = [Unit(model.TYPE, model.unit_key, model.metadata, '') for model in deps]

        # the first call to filter gets all the dependencies for the parent repository
        # The second time it is called during the recursion and all the units have already
        # been copied.
        mock_filter.side_effect = iter([dep_units, []])
        # The get existing units always assumes there are no units in the target repository
        mock_get_existing.return_value = []
        unit_set = associate.copy_rpms(rpms, conduit, True)

        merged_set = set(dep_units)
        merged_set.update(rpms)
        self.assertEquals(unit_set, merged_set)