Created
April 29, 2016 18:55
-
-
Save jaredlockhart/ad9902af5af27f50b0c31407d6c54384 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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