コード例 #1
0
    def test_get_file_units(self, mock_generator):
        # Setup
        self.sample_comps_filename = os.path.join(DATA_DIR,
                                                  'simple_repo_comps',
                                                  XML_FILENAME)
        mock_repo = mock.MagicMock()
        mock_repo.id = 'some_id'
        mock_conduit = mock.MagicMock()
        mock_process_element = mock.Mock()
        category = tuple(model_factory.category_models(3))
        mock_generator.return_value = category

        # Test
        upload._get_file_units(self.sample_comps_filename,
                               mock_process_element, 'foo', mock_conduit,
                               mock_repo.id)

        # Verify
        self.assertEqual(mock_generator.call_count, 1)

        for model in category:
            mock_conduit.init_unit.assert_any_call(model.TYPE, model.unit_key,
                                                   model.metadata, None)
            mock_conduit.save_unit.assert_any_call(
                mock_conduit.init_unit.return_value)
        self.assertEqual(mock_conduit.save_unit.call_count, 3)
コード例 #2
0
ファイル: test_upload.py プロジェクト: dkliban/pulp_rpm
    def test_get_file_units(self, mock_generator):
        # Setup
        self.sample_comps_filename = os.path.join(DATA_DIR, 'simple_repo_comps', XML_FILENAME)
        mock_repo = mock.MagicMock()
        mock_repo.id = 'some_id'
        mock_conduit = mock.MagicMock()
        mock_process_element = mock.Mock()
        category = tuple(model_factory.category_models(3))
        mock_generator.return_value = category

        # Test
        upload._get_file_units(self.sample_comps_filename, mock_process_element, 'foo',
                               mock_conduit, mock_repo.id)

        # Verify
        self.assertEqual(mock_generator.call_count, 1)

        for model in category:
            mock_conduit.init_unit.assert_any_call(model.TYPE, model.unit_key, model.metadata, None)
            mock_conduit.save_unit.assert_any_call(mock_conduit.init_unit.return_value)
        self.assertEqual(mock_conduit.save_unit.call_count, 3)