예제 #1
0
    def test_all_in_source(self, mock_copy):
        rpms = model_factory.rpm_units(2)
        names = [r.unit_key['name'] for r in rpms]
        conduit = mock.MagicMock()
        conduit.get_source_units.return_value = rpms

        associate.copy_rpms_by_name(names, conduit, False)

        self.assertEqual(conduit.get_source_units.call_count, 1)
        to_copy = list(mock_copy.call_args[0][0])
        self.assertEqual(len(to_copy), 2)
        for unit in to_copy:
            self.assertTrue(isinstance(unit, Unit))
            self.assertTrue(unit.unit_key['name'] in names)
        self.assertFalse(mock_copy.call_args[0][2])
예제 #2
0
    def test_all_in_source(self, mock_copy):
        rpms = model_factory.rpm_units(2)
        names = [r.unit_key['name'] for r in rpms]
        conduit = mock.MagicMock()
        conduit.get_source_units.return_value = rpms

        associate.copy_rpms_by_name(names, conduit, False)

        self.assertEqual(conduit.get_source_units.call_count, 1)
        to_copy = list(mock_copy.call_args[0][0])
        self.assertEqual(len(to_copy), 2)
        for unit in to_copy:
            self.assertTrue(isinstance(unit, Unit))
            self.assertTrue(unit.unit_key['name'] in names)
        self.assertFalse(mock_copy.call_args[0][2])
예제 #3
0
    def test_multiple_versions(self, mock_copy):
        rpms = model_factory.rpm_units(2, True)
        names = list(set([r.unit_key['name'] for r in rpms]))
        conduit = mock.MagicMock()
        conduit.get_source_units.return_value = rpms

        associate.copy_rpms_by_name(names, conduit, False)

        self.assertEqual(conduit.get_source_units.call_count, 1)
        to_copy = list(mock_copy.call_args[0][0])
        self.assertEqual(len(to_copy), 1)
        unit = to_copy[0]
        self.assertTrue(isinstance(unit, Unit))
        self.assertTrue(unit.unit_key['name'] in names)
        self.assertEqual(unit.unit_key['version'], rpms[1].unit_key['version'])
        self.assertFalse(mock_copy.call_args[0][2])
예제 #4
0
    def test_multiple_versions(self, mock_copy):
        rpms = model_factory.rpm_units(2, True)
        names = list(set([r.unit_key['name'] for r in rpms]))
        conduit = mock.MagicMock()
        conduit.get_source_units.return_value = rpms

        associate.copy_rpms_by_name(names, conduit, False)

        self.assertEqual(conduit.get_source_units.call_count, 1)
        to_copy = list(mock_copy.call_args[0][0])
        self.assertEqual(len(to_copy), 1)
        unit = to_copy[0]
        self.assertTrue(isinstance(unit, Unit))
        self.assertTrue(unit.unit_key['name'] in names)
        self.assertEqual(unit.unit_key['version'], rpms[1].unit_key['version'])
        self.assertFalse(mock_copy.call_args[0][2])