コード例 #1
0
    def test_run_search_with_field_filters(self, mock_search):
        # Setup
        mock_out = mock.MagicMock()
        units = [{'a': 'a', 'metadata': 'm'}]
        mock_search.return_value = Response(200, units)

        user_input = {
            'repo-id': 'repo-1',
            DisplayUnitAssociationsCommand.ASSOCIATION_FLAG.keyword: False,
        }

        # Test
        command = contents.BaseSearchCommand(None, self.context)
        command.run_search([contents.TYPE_RPM],
                           out_func=mock_out,
                           **user_input)

        # Verify
        expected = {
            'type_ids': [contents.TYPE_RPM],
            DisplayUnitAssociationsCommand.ASSOCIATION_FLAG.keyword: False,
        }
        mock_search.assert_called_once_with('repo-1', **expected)
        mock_out.assert_called_once_with(
            ['m'], contents.FIELDS_BY_TYPE[contents.TYPE_RPM])
コード例 #2
0
ファイル: test_contents.py プロジェクト: ulif/pulp_rpm
    def test_run_search_no_details(self, mock_search):
        # Setup
        mock_out = mock.MagicMock()
        units = [{'a': 'a', 'metadata': 'm'}]
        mock_search.return_value = Response(200, units)

        user_input = {
            'repo-id': 'repo-1',
            DisplayUnitAssociationsCommand.ASSOCIATION_FLAG.keyword: False,
        }

        # Test
        command = contents.BaseSearchCommand(None, self.context)
        command.run_search(['fake-type'], out_func=mock_out, **user_input)

        # Verify
        expected = {
            'type_ids': ['fake-type'],
            DisplayUnitAssociationsCommand.ASSOCIATION_FLAG.keyword: False,
        }
        mock_search.assert_called_once_with('repo-1', **expected)
        mock_out.assert_called_once_with(['m'])  # only the metadata due to no details