Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jaredlockhart/ad9902af5af27f50b0c31407d6c54384 to your computer and use it in GitHub Desktop.
Save jaredlockhart/ad9902af5af27f50b0c31407d6c54384 to your computer and use it in GitHub Desktop.
class MyModel(models.Model):
name = models.CharField()
@property
def github_contributors(self):
return github.get_contributors(self.github_user, self.github_repo)
class MyModelSerializer(Serializer):
class Meta:
model = MyModel
fields = ('name', 'github_contributors')
def test_get_mymodel(self):
instance = MyModelFactory()
response = self.client.get(reverse('detail-view', kwargs={'id': instance.id}))
response_data = json.loads(response.content)
self.assertEqual(response_data, {
'name': instance.name,
'github_contributors': instance.github_contributors,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment