Exemple #1
0
    def test_simple(self):
        serializer = ReleaseSerializer(
            data={
                'version': self.version,
                'owner': self.user.username,
                'ref': self.ref,
                'url': self.url,
                'dateReleased': self.dateReleased,
                'commits': self.commits,
            })

        assert serializer.is_valid()
        assert sorted(serializer.fields.keys()) == sorted(
            ['version', 'owner', 'ref', 'url', 'dateReleased', 'commits'])

        result = serializer.object
        assert result['version'] == self.version
        assert result['owner'] == self.user
        assert result['ref'] == self.ref
        assert result['url'] == self.url
        assert result['dateReleased'] == datetime(1000, 10, 10, 6, 6)
        assert result['commits'] == self.commits
Exemple #2
0
 def test_version_does_not_allow_null_or_empty_value(self):
     serializer = ReleaseSerializer(data={
         'version': None,
     })
     assert not serializer.is_valid()
     serializer = ReleaseSerializer(data={
         'version': '',
     })
     assert not serializer.is_valid()
Exemple #3
0
 def test_version_does_not_allow_current_dir_path(self):
     serializer = ReleaseSerializer(data={
         'version': '.',
     })
     assert not serializer.is_valid()
     serializer = ReleaseSerializer(data={
         'version': '..',
     })
     assert not serializer.is_valid()
Exemple #4
0
 def test_version_limited_by_max_version_length(self):
     serializer = ReleaseSerializer(data={
         'version': 'a' * VERSION_LENGTH,
     })
     assert serializer.is_valid()
     serializer = ReleaseSerializer(data={
         'version': 'a' * (VERSION_LENGTH + 1),
     })
     assert not serializer.is_valid()
Exemple #5
0
 def test_version_does_not_allow_whitespace(self):
     for char in BAD_RELEASE_CHARS:
         serializer = ReleaseSerializer(data={
             'version': char,
         })
         assert not serializer.is_valid()
Exemple #6
0
 def test_do_not_allow_null_commits(self):
     serializer = ReleaseSerializer(data={
         'version': self.version,
         'commits': None,
     })
     assert not serializer.is_valid()
Exemple #7
0
 def test_fields_not_required(self):
     serializer = ReleaseSerializer(data={'version': self.version})
     assert serializer.is_valid()