{"action":"created","comment":{"url":"https://api.github.com/repos/ProjetSigma/backend/pulls/comments/51493411","id":51493411,"diff_hunk":"@@ -0,0 +1,56 @@\n+import json\n+from PIL import Image\n+\n+from django.core.files.uploadedfile import SimpleUploadedFile\n+\n+from rest_framework import status\n+from rest_framework.test import APITestCase, force_authenticate\n+\n+from sigma_core.tests.factories import UserFactory\n+from sigma_core.serializers.user import DetailedUserSerializer as UserSerializer\n+from sigma_files.models import ProfileImage\n+from sigma_files.serializers import ProfileImageSerializer\n+\n+\n+class ProfileImageTests(APITestCase):\n+    @classmethod\n+    def setUpTestData(self):\n+        super(ProfileImageTests, self).setUpTestData()\n+\n+        self.user = UserFactory()\n+        file = SimpleUploadedFile(name='test.jpg', content=Image.new('RGB', (15, 15)).tobytes(), content_type='image/jpeg')\n+        self.profile_image = ProfileImage.objects.create(file=file)\n+\n+        self.user.photo = self.profile_image\n+        self.user.save()\n+\n+        serializer = ProfileImageSerializer(self.profile_image)\n+        self.profile_data = serializer.data\n+        self.profiles_url = '/profile-image/'\n+        self.profile_url = self.profiles_url + '%d/' % self.profile_image.id\n+\n+    def test_get_list_unauthed(self):\n+        # Client not authenticated\n+        response = self.client.get(self.profiles_url)\n+        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)\n+\n+    def test_get_list_ok(self):\n+        self.client.force_authenticate(user=self.user)\n+        response = self.client.get(self.profiles_url)\n+        self.assertEqual(response.status_code, status.HTTP_200_OK)\n+\n+    def test_get_one_ok(self):\n+        self.client.force_authenticate(user=self.user)\n+        response = self.client.get(self.profile_url)\n+        self.assertEqual(response.status_code, status.HTTP_200_OK)\n+\n+    def test_create_unauthed(self):\n+        with open(\"sigma_files/test_img.png\", \"rb\") as img:\n+             response = self.client.post(self.profiles_url, {'file': img}, format='multipart')\n+        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)\n+\n+    def test_create_ok(self):\n+        self.client.force_authenticate(user=self.user)\n+        with open(\"sigma_files/test_img.png\", \"rb\") as img:\n+             response = self.client.post(self.profiles_url, {'file': img}, format='multipart')\n+        self.assertEqual(response.status_code, status.HTTP_201_CREATED)","path":"sigma_files/tests.py","position":56,"original_position":56,"commit_id":"cb362be7288435ff6d523e9d4a3e16ba871e6759","original_commit_id":"cb362be7288435ff6d523e9d4a3e16ba871e6759","user":{"login":"tizot","id":8040983,"avatar_url":"https://avatars.githubusercontent.com/u/8040983?v=3","gravatar_id":"","url":"https://api.github.com/users/tizot","html_url":"https://github.com/tizot","followers_url":"https://api.github.com/users/tizot/followers","following_url":"https://api.github.com/users/tizot/following{/other_user}","gists_url":"https://api.github.com/users/tizot/gists{/gist_id}","starred_url":"https://api.github.com/users/tizot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tizot/subscriptions","organizations_url":"https://api.github.com/users/tizot/orgs","repos_url":"https://api.github.com/users/tizot/repos","events_url":"https://api.github.com/users/tizot/events{/privacy}","received_events_url":"https://api.github.com/users/tizot/received_events","type":"User","site_admin":false},"body":"À vérifier, mais il me semble que Django fait déjà tout ça : c'est un champ de type `ImageField`.\r\nPour la limite de taille, c'est la config du serveur qui joue, non ?","created_at":"2016-02-01T22:40:27Z","updated_at":"2016-02-01T22:40:27Z","html_url":"https://github.com/ProjetSigma/backend/pull/21#discussion_r51493411","pull_request_url":"https://api.github.com/repos/ProjetSigma/backend/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/comments/51493411"},"html":{"href":"https://github.com/ProjetSigma/backend/pull/21#discussion_r51493411"},"pull_request":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/ProjetSigma/backend/pulls/21","id":57899972,"html_url":"https://github.com/ProjetSigma/backend/pull/21","diff_url":"https://github.com/ProjetSigma/backend/pull/21.diff","patch_url":"https://github.com/ProjetSigma/backend/pull/21.patch","issue_url":"https://api.github.com/repos/ProjetSigma/backend/issues/21","number":21,"state":"open","locked":false,"title":"Feature/84 profile photo","user":{"login":"tizot","id":8040983,"avatar_url":"https://avatars.githubusercontent.com/u/8040983?v=3","gravatar_id":"","url":"https://api.github.com/users/tizot","html_url":"https://github.com/tizot","followers_url":"https://api.github.com/users/tizot/followers","following_url":"https://api.github.com/users/tizot/following{/other_user}","gists_url":"https://api.github.com/users/tizot/gists{/gist_id}","starred_url":"https://api.github.com/users/tizot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tizot/subscriptions","organizations_url":"https://api.github.com/users/tizot/orgs","repos_url":"https://api.github.com/users/tizot/repos","events_url":"https://api.github.com/users/tizot/events{/privacy}","received_events_url":"https://api.github.com/users/tizot/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-01T21:07:35Z","updated_at":"2016-02-01T22:40:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa3ba6af2cc5196012f86901ccacb0a44347fb90","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ProjetSigma/backend/pulls/21/commits","review_comments_url":"https://api.github.com/repos/ProjetSigma/backend/pulls/21/comments","review_comment_url":"https://api.github.com/repos/ProjetSigma/backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ProjetSigma/backend/issues/21/comments","statuses_url":"https://api.github.com/repos/ProjetSigma/backend/statuses/cb362be7288435ff6d523e9d4a3e16ba871e6759","head":{"label":"ProjetSigma:feature/84-profile-photo","ref":"feature/84-profile-photo","sha":"cb362be7288435ff6d523e9d4a3e16ba871e6759","user":{"login":"ProjetSigma","id":14943240,"avatar_url":"https://avatars.githubusercontent.com/u/14943240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProjetSigma","html_url":"https://github.com/ProjetSigma","followers_url":"https://api.github.com/users/ProjetSigma/followers","following_url":"https://api.github.com/users/ProjetSigma/following{/other_user}","gists_url":"https://api.github.com/users/ProjetSigma/gists{/gist_id}","starred_url":"https://api.github.com/users/ProjetSigma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProjetSigma/subscriptions","organizations_url":"https://api.github.com/users/ProjetSigma/orgs","repos_url":"https://api.github.com/users/ProjetSigma/repos","events_url":"https://api.github.com/users/ProjetSigma/events{/privacy}","received_events_url":"https://api.github.com/users/ProjetSigma/received_events","type":"Organization","site_admin":false},"repo":{"id":46338491,"name":"backend","full_name":"ProjetSigma/backend","owner":{"login":"ProjetSigma","id":14943240,"avatar_url":"https://avatars.githubusercontent.com/u/14943240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProjetSigma","html_url":"https://github.com/ProjetSigma","followers_url":"https://api.github.com/users/ProjetSigma/followers","following_url":"https://api.github.com/users/ProjetSigma/following{/other_user}","gists_url":"https://api.github.com/users/ProjetSigma/gists{/gist_id}","starred_url":"https://api.github.com/users/ProjetSigma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProjetSigma/subscriptions","organizations_url":"https://api.github.com/users/ProjetSigma/orgs","repos_url":"https://api.github.com/users/ProjetSigma/repos","events_url":"https://api.github.com/users/ProjetSigma/events{/privacy}","received_events_url":"https://api.github.com/users/ProjetSigma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProjetSigma/backend","description":"Back-end of Projet Sigma","fork":false,"url":"https://api.github.com/repos/ProjetSigma/backend","forks_url":"https://api.github.com/repos/ProjetSigma/backend/forks","keys_url":"https://api.github.com/repos/ProjetSigma/backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProjetSigma/backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProjetSigma/backend/teams","hooks_url":"https://api.github.com/repos/ProjetSigma/backend/hooks","issue_events_url":"https://api.github.com/repos/ProjetSigma/backend/issues/events{/number}","events_url":"https://api.github.com/repos/ProjetSigma/backend/events","assignees_url":"https://api.github.com/repos/ProjetSigma/backend/assignees{/user}","branches_url":"https://api.github.com/repos/ProjetSigma/backend/branches{/branch}","tags_url":"https://api.github.com/repos/ProjetSigma/backend/tags","blobs_url":"https://api.github.com/repos/ProjetSigma/backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProjetSigma/backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProjetSigma/backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProjetSigma/backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProjetSigma/backend/statuses/{sha}","languages_url":"https://api.github.com/repos/ProjetSigma/backend/languages","stargazers_url":"https://api.github.com/repos/ProjetSigma/backend/stargazers","contributors_url":"https://api.github.com/repos/ProjetSigma/backend/contributors","subscribers_url":"https://api.github.com/repos/ProjetSigma/backend/subscribers","subscription_url":"https://api.github.com/repos/ProjetSigma/backend/subscription","commits_url":"https://api.github.com/repos/ProjetSigma/backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProjetSigma/backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProjetSigma/backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProjetSigma/backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProjetSigma/backend/contents/{+path}","compare_url":"https://api.github.com/repos/ProjetSigma/backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProjetSigma/backend/merges","archive_url":"https://api.github.com/repos/ProjetSigma/backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProjetSigma/backend/downloads","issues_url":"https://api.github.com/repos/ProjetSigma/backend/issues{/number}","pulls_url":"https://api.github.com/repos/ProjetSigma/backend/pulls{/number}","milestones_url":"https://api.github.com/repos/ProjetSigma/backend/milestones{/number}","notifications_url":"https://api.github.com/repos/ProjetSigma/backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProjetSigma/backend/labels{/name}","releases_url":"https://api.github.com/repos/ProjetSigma/backend/releases{/id}","deployments_url":"https://api.github.com/repos/ProjetSigma/backend/deployments","created_at":"2015-11-17T10:01:22Z","updated_at":"2016-01-15T10:49:26Z","pushed_at":"2016-02-01T21:11:20Z","git_url":"git://github.com/ProjetSigma/backend.git","ssh_url":"git@github.com:ProjetSigma/backend.git","clone_url":"https://github.com/ProjetSigma/backend.git","svn_url":"https://github.com/ProjetSigma/backend","homepage":null,"size":251,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"ProjetSigma:master","ref":"master","sha":"a78a43aa380b15adc879888a318f29c9c805d34c","user":{"login":"ProjetSigma","id":14943240,"avatar_url":"https://avatars.githubusercontent.com/u/14943240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProjetSigma","html_url":"https://github.com/ProjetSigma","followers_url":"https://api.github.com/users/ProjetSigma/followers","following_url":"https://api.github.com/users/ProjetSigma/following{/other_user}","gists_url":"https://api.github.com/users/ProjetSigma/gists{/gist_id}","starred_url":"https://api.github.com/users/ProjetSigma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProjetSigma/subscriptions","organizations_url":"https://api.github.com/users/ProjetSigma/orgs","repos_url":"https://api.github.com/users/ProjetSigma/repos","events_url":"https://api.github.com/users/ProjetSigma/events{/privacy}","received_events_url":"https://api.github.com/users/ProjetSigma/received_events","type":"Organization","site_admin":false},"repo":{"id":46338491,"name":"backend","full_name":"ProjetSigma/backend","owner":{"login":"ProjetSigma","id":14943240,"avatar_url":"https://avatars.githubusercontent.com/u/14943240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProjetSigma","html_url":"https://github.com/ProjetSigma","followers_url":"https://api.github.com/users/ProjetSigma/followers","following_url":"https://api.github.com/users/ProjetSigma/following{/other_user}","gists_url":"https://api.github.com/users/ProjetSigma/gists{/gist_id}","starred_url":"https://api.github.com/users/ProjetSigma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProjetSigma/subscriptions","organizations_url":"https://api.github.com/users/ProjetSigma/orgs","repos_url":"https://api.github.com/users/ProjetSigma/repos","events_url":"https://api.github.com/users/ProjetSigma/events{/privacy}","received_events_url":"https://api.github.com/users/ProjetSigma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProjetSigma/backend","description":"Back-end of Projet Sigma","fork":false,"url":"https://api.github.com/repos/ProjetSigma/backend","forks_url":"https://api.github.com/repos/ProjetSigma/backend/forks","keys_url":"https://api.github.com/repos/ProjetSigma/backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProjetSigma/backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProjetSigma/backend/teams","hooks_url":"https://api.github.com/repos/ProjetSigma/backend/hooks","issue_events_url":"https://api.github.com/repos/ProjetSigma/backend/issues/events{/number}","events_url":"https://api.github.com/repos/ProjetSigma/backend/events","assignees_url":"https://api.github.com/repos/ProjetSigma/backend/assignees{/user}","branches_url":"https://api.github.com/repos/ProjetSigma/backend/branches{/branch}","tags_url":"https://api.github.com/repos/ProjetSigma/backend/tags","blobs_url":"https://api.github.com/repos/ProjetSigma/backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProjetSigma/backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProjetSigma/backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProjetSigma/backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProjetSigma/backend/statuses/{sha}","languages_url":"https://api.github.com/repos/ProjetSigma/backend/languages","stargazers_url":"https://api.github.com/repos/ProjetSigma/backend/stargazers","contributors_url":"https://api.github.com/repos/ProjetSigma/backend/contributors","subscribers_url":"https://api.github.com/repos/ProjetSigma/backend/subscribers","subscription_url":"https://api.github.com/repos/ProjetSigma/backend/subscription","commits_url":"https://api.github.com/repos/ProjetSigma/backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProjetSigma/backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProjetSigma/backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProjetSigma/backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProjetSigma/backend/contents/{+path}","compare_url":"https://api.github.com/repos/ProjetSigma/backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProjetSigma/backend/merges","archive_url":"https://api.github.com/repos/ProjetSigma/backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProjetSigma/backend/downloads","issues_url":"https://api.github.com/repos/ProjetSigma/backend/issues{/number}","pulls_url":"https://api.github.com/repos/ProjetSigma/backend/pulls{/number}","milestones_url":"https://api.github.com/repos/ProjetSigma/backend/milestones{/number}","notifications_url":"https://api.github.com/repos/ProjetSigma/backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProjetSigma/backend/labels{/name}","releases_url":"https://api.github.com/repos/ProjetSigma/backend/releases{/id}","deployments_url":"https://api.github.com/repos/ProjetSigma/backend/deployments","created_at":"2015-11-17T10:01:22Z","updated_at":"2016-01-15T10:49:26Z","pushed_at":"2016-02-01T21:11:20Z","git_url":"git://github.com/ProjetSigma/backend.git","ssh_url":"git@github.com:ProjetSigma/backend.git","clone_url":"https://github.com/ProjetSigma/backend.git","svn_url":"https://github.com/ProjetSigma/backend","homepage":null,"size":251,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/21"},"html":{"href":"https://github.com/ProjetSigma/backend/pull/21"},"issue":{"href":"https://api.github.com/repos/ProjetSigma/backend/issues/21"},"comments":{"href":"https://api.github.com/repos/ProjetSigma/backend/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ProjetSigma/backend/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/ProjetSigma/backend/statuses/cb362be7288435ff6d523e9d4a3e16ba871e6759"}}}}