Example #1
0
    def test_get_by_name_too_few_matches(self, mock_index, mock_detail):
        """Validate using a string that returns too few (no) results."""

        mock_index.return_value = []

        with self.assertRaises(SystemExit):
            bundle._get_bundle('test')
Example #2
0
    def test_get_by_name_too_many_matches(self, mock_index, mock_detail):
        """Validate using a string that returns too many results."""

        # not valid return values (should be a JSON response) but good enough
        mock_index.return_value = ['hello, world', 'uh oh']

        with self.assertRaises(SystemExit):
            bundle._get_bundle('test')
Example #3
0
    def test_get_by_name(self, mock_index, mock_detail):
        """Validate using a string (bundle name)."""

        # not a valid return value (should be a JSON response) but good enough
        mock_index.return_value = ['hello, world']

        result = bundle._get_bundle('test')

        assert result == mock_index.return_value[0], result
        mock_detail.assert_not_called()
        mock_index.assert_called_once_with('bundles', [('q', 'test')])
Example #4
0
    def test_get_by_id(self, mock_index, mock_detail):
        """Validate using a number (bundle ID)."""

        # not a valid return value (should be a JSON response) but good enough
        mock_detail.return_value = 'hello, world'

        result = bundle._get_bundle('123')

        assert result == mock_detail.return_value, result
        mock_index.assert_not_called()
        mock_detail.assert_called_once_with('bundles', '123')