def test_ref_limited_by_max_version_length(self): serializer = ReleaseSerializer(data={ 'ref': 'a' * MAX_VERSION_LENGTH, }) assert serializer.is_valid() serializer = ReleaseSerializer(data={ 'ref': 'a' * (MAX_VERSION_LENGTH + 1), }) assert not serializer.is_valid()
def test_ref_limited_by_max_version_length(self): serializer = ReleaseSerializer(data={ 'ref': 'a' * VERSION_LENGTH, }) assert serializer.is_valid() serializer = ReleaseSerializer(data={ 'ref': 'a' * (VERSION_LENGTH + 1), }) assert not serializer.is_valid()
def test_simple(self): serializer = ReleaseSerializer(data={ 'ref': self.ref, 'url': self.url, 'dateReleased': self.dateReleased, 'commits': self.commits, }) assert serializer.is_valid() assert sorted(serializer.fields.keys()) == sorted(['ref', 'url', 'dateReleased', 'commits']) result = serializer.object assert result['ref'] == self.ref assert result['url'] == self.url assert result['dateReleased'] == datetime(1000, 10, 10, 6, 6) assert result['commits'] == self.commits
def test_simple(self): serializer = ReleaseSerializer( data={ "ref": self.ref, "url": self.url, "dateReleased": self.dateReleased, "commits": self.commits, }) assert serializer.is_valid() assert sorted(serializer.fields.keys()) == sorted( ["ref", "url", "dateReleased", "commits"]) result = serializer.validated_data assert result["ref"] == self.ref assert result["url"] == self.url assert result["dateReleased"] == datetime(1000, 10, 10, 6, 6, tzinfo=pytz.UTC) assert result["commits"] == self.commits
def test_do_not_allow_null_commits(self): serializer = ReleaseSerializer({ 'commits': None, }) assert not serializer.is_valid()
def test_fields_not_required(self): serializer = ReleaseSerializer(data={}) assert serializer.is_valid()
def test_ref_limited_by_max_version_length(self): serializer = ReleaseSerializer(data={"ref": "a" * MAX_VERSION_LENGTH}) assert serializer.is_valid() serializer = ReleaseSerializer( data={"ref": "a" * (MAX_VERSION_LENGTH + 1)}) assert not serializer.is_valid()
def test_do_not_allow_null_commits(self): serializer = ReleaseSerializer(data={"commits": None}) assert not serializer.is_valid()