Exemplo n.º 1
0
    def test_simple(self):
        # test bad refs
        data = {
            'version': 'a' * 40,
            'projects': ['earth'],
            'refs': [None]
        }

        serializer = ReleaseSerializerWithProjects(data=data)

        assert not serializer.is_valid()
        assert serializer.errors == {
            'refs': [u'Incorrect type. Expected value, but got null'],
        }

        # test good refs
        data = {
            'version': 'a' * 40,
            'projects': ['earth'],
            'refs': [{
                'repository': 'my-repo',
                'commit': 'b' * 40,
            }]
        }

        serializer = ReleaseSerializerWithProjects(data=data)

        assert serializer.is_valid()
Exemplo n.º 2
0
    def test_simple(self):
        # test bad refs
        data = {"version": "a" * 40, "projects": ["earth"], "refs": [None]}

        serializer = ReleaseSerializerWithProjects(data=data)

        assert not serializer.is_valid()
        assert serializer.errors == {"refs": ["This field may not be null."]}

        # test good refs
        data = {
            "version": "a" * 40,
            "projects": ["earth"],
            "refs": [{"repository": "my-repo", "commit": "b" * 40}],
        }

        serializer = ReleaseSerializerWithProjects(data=data)

        assert serializer.is_valid()
    def test_simple(self):
        # test bad refs
        data = {'version': 'a' * 40, 'projects': ['earth'], 'refs': [None]}

        serializer = ReleaseSerializerWithProjects(data=data)

        assert not serializer.is_valid()
        assert serializer.errors == {
            'refs': ['non_field_errors: No input provided'],
        }

        # test good refs
        data = {
            'version': 'a' * 40,
            'projects': ['earth'],
            'refs': [{
                'repository': 'my-repo',
                'commit': 'b' * 40,
            }]
        }

        serializer = ReleaseSerializerWithProjects(data=data)

        assert serializer.is_valid()