Beispiel #1
0
    def test_valid_from_tag(self):
        """A request with valid from_tag should pass without errors."""
        self.request.validated['from_tag'] = 'f30-something-side-tag'

        validators.validate_builds_or_from_tag_exist(self.request)

        assert len(self.request.errors) == 0
Beispiel #2
0
    def test_valid_builds(self):
        """A request with valid builds should pass without errors."""
        self.request.validated['builds'] = ['foo-1-1.fc30']

        validators.validate_builds_or_from_tag_exist(self.request)

        assert len(self.request.errors) == 0
Beispiel #3
0
    def test_missing(self):
        """A request without `builds` or `from_tag` should add an error."""
        validators.validate_builds_or_from_tag_exist(self.request)

        assert self.request.errors == [
            {'location': 'body', 'name': 'builds,from_tag',
             'description': "You must specify either builds or from_tag."}
        ]
Beispiel #4
0
    def test_empty_from_tag(self):
        """An empty from_tag should add an error to the request."""
        self.request.validated['from_tag'] = ""

        validators.validate_builds_or_from_tag_exist(self.request)

        assert self.request.errors == [
            {'location': 'body', 'name': 'from_tag',
             'description': "You may not specify an empty from_tag."}
        ]
Beispiel #5
0
    def test_invalid_from_tag(self):
        """A request with wrongly typed from_tag should add an error."""
        self.request.validated['from_tag'] = ['f30-something-side-tag']

        validators.validate_builds_or_from_tag_exist(self.request)

        assert self.request.errors == [
            {'location': 'body', 'name': 'from_tag',
             'description': 'The from_tag parameter must be a string.'}
        ]
Beispiel #6
0
    def test_invalid_builds(self):
        """A request with wrongly typed builds should add an error."""
        self.request.validated['builds'] = 'foo-1-1.fc30'

        validators.validate_builds_or_from_tag_exist(self.request)

        assert self.request.errors == [
            {'location': 'body', 'name': 'builds',
             'description': 'The builds parameter must be a list.'}
        ]