Skip to content

Commit

Permalink
Test commit serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Katie Lundsgaard committed Jan 27, 2017
1 parent 8851b3f commit 918ac56
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/sentry/api/serializers/test_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from uuid import uuid4

from sentry.api.serializers import serialize
from sentry.models import (Commit, CommitAuthor,
Release, ReleaseCommit, Repository)
from sentry.testutils import TestCase


class CommitSerializerTest(TestCase):
def test_simple(self):
user = self.create_user()
project = self.create_project()
release = Release.objects.create(
organization_id=project.organization_id,
version=uuid4().hex,
)
release.add_project(project)
repository = Repository.objects.create(
organization_id=project.organization_id,
name='test/test',
)
commit_author = CommitAuthor.objects.create(
name='stebe',
email='[email protected]',
organization_id=project.organization_id,
)
commit = Commit.objects.create(
organization_id=project.organization_id,
repository_id=repository.id,
key='abc',
author=commit_author,
message='waddap',
)
ReleaseCommit.objects.create(
organization_id=project.organization_id,
project_id=project.id,
release=release,
commit=commit,
order=1,
)
result = serialize(commit, user)

assert result['message'] == 'waddap'
assert result['repository']['name'] == 'test/test'
assert result['author'] == {'name': 'stebe', 'email': '[email protected]'}

0 comments on commit 918ac56

Please sign in to comment.