{"action":"created","comment":{"url":"https://api.github.com/repos/openfun/edx-gea/pulls/comments/35299526","id":35299526,"diff_hunk":"@@ -1,4 +1,109 @@\n-import unittest\n+import csv\n+from mock import Mock\n+import os\n+import tempfile\n \n-class GradeExternalActivityXBlockTests(unittest.TestCase):\n-    pass\n+from django.core.files.uploadedfile import SimpleUploadedFile\n+from django.test.client import RequestFactory\n+\n+from courseware.grades import iterate_grades_for\n+from student.tests.factories import UserFactory, CourseEnrollmentFactory\n+\n+from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase\n+from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory\n+\n+from edx_gea.forms import UploadAssessmentFileForm\n+\n+\n+class GradeExternalActivityXBlockTests(ModuleStoreTestCase):\n+    def setUp(self):\n+        super(GradeExternalActivityXBlockTests, self).setUp(create_user=False)\n+        self.course = CourseFactory.create(grading_policy={\n+            \"GRADER\": [{\n+                \"type\": \"Homework\",\n+                \"min_count\": 1,\n+                \"drop_count\": 0,\n+                \"short_label\": \"HW\",\n+                \"weight\": 1.0\n+            }]})\n+        self.gea_xblock = None\n+        self.generate_modules_tree(self.course, 'chapter', 'sequential',\n+                                   'vertical', 'edx_gea')\n+\n+    def test_staff_view_is_called(self):\n+        self.gea_xblock.xmodule_runtime = Mock()\n+        self.gea_xblock.xmodule_runtime.user_is_staff = True\n+        self.gea_xblock.staff_view = Mock()\n+        self.gea_xblock.student_view()\n+        self.gea_xblock.staff_view.assert_called()\n+\n+    def create_csv(self, *args):\n+        input_file = tempfile.NamedTemporaryFile()\n+        writer = csv.writer(input_file)\n+        for arg in args:\n+            writer.writerow(arg)\n+        input_file.flush()\n+        os.fsync(input_file)","path":"edx_gea/tests.py","position":49,"original_position":49,"commit_id":"86c1cda1a3b792ea5ae5c3f2847bb9c3c8995e91","original_commit_id":"86c1cda1a3b792ea5ae5c3f2847bb9c3c8995e91","user":{"login":"jpaille","id":2971857,"avatar_url":"https://avatars.githubusercontent.com/u/2971857?v=3","gravatar_id":"","url":"https://api.github.com/users/jpaille","html_url":"https://github.com/jpaille","followers_url":"https://api.github.com/users/jpaille/followers","following_url":"https://api.github.com/users/jpaille/following{/other_user}","gists_url":"https://api.github.com/users/jpaille/gists{/gist_id}","starred_url":"https://api.github.com/users/jpaille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpaille/subscriptions","organizations_url":"https://api.github.com/users/jpaille/orgs","repos_url":"https://api.github.com/users/jpaille/repos","events_url":"https://api.github.com/users/jpaille/events{/privacy}","received_events_url":"https://api.github.com/users/jpaille/received_events","type":"User","site_admin":false},"body":"Non c’était pour mon debug. ok","created_at":"2015-07-23T08:27:32Z","updated_at":"2015-07-23T08:27:32Z","html_url":"https://github.com/openfun/edx-gea/pull/1#discussion_r35299526","pull_request_url":"https://api.github.com/repos/openfun/edx-gea/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/comments/35299526"},"html":{"href":"https://github.com/openfun/edx-gea/pull/1#discussion_r35299526"},"pull_request":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/openfun/edx-gea/pulls/1","id":40449104,"html_url":"https://github.com/openfun/edx-gea/pull/1","diff_url":"https://github.com/openfun/edx-gea/pull/1.diff","patch_url":"https://github.com/openfun/edx-gea/pull/1.patch","issue_url":"https://api.github.com/repos/openfun/edx-gea/issues/1","number":1,"state":"open","locked":false,"title":"Add Grade External Activity XBlock.","user":{"login":"jpaille","id":2971857,"avatar_url":"https://avatars.githubusercontent.com/u/2971857?v=3","gravatar_id":"","url":"https://api.github.com/users/jpaille","html_url":"https://github.com/jpaille","followers_url":"https://api.github.com/users/jpaille/followers","following_url":"https://api.github.com/users/jpaille/following{/other_user}","gists_url":"https://api.github.com/users/jpaille/gists{/gist_id}","starred_url":"https://api.github.com/users/jpaille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpaille/subscriptions","organizations_url":"https://api.github.com/users/jpaille/orgs","repos_url":"https://api.github.com/users/jpaille/repos","events_url":"https://api.github.com/users/jpaille/events{/privacy}","received_events_url":"https://api.github.com/users/jpaille/received_events","type":"User","site_admin":false},"body":"XBlock permettant de noter une activité externe à edX.\r\nticket : https://fun.plan.io/issues/1533","created_at":"2015-07-21T11:57:31Z","updated_at":"2015-07-23T08:27:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6af8d52b356ac298caa9f14149d4a71028f23708","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openfun/edx-gea/pulls/1/commits","review_comments_url":"https://api.github.com/repos/openfun/edx-gea/pulls/1/comments","review_comment_url":"https://api.github.com/repos/openfun/edx-gea/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openfun/edx-gea/issues/1/comments","statuses_url":"https://api.github.com/repos/openfun/edx-gea/statuses/86c1cda1a3b792ea5ae5c3f2847bb9c3c8995e91","head":{"label":"openfun:dev","ref":"dev","sha":"86c1cda1a3b792ea5ae5c3f2847bb9c3c8995e91","user":{"login":"openfun","id":7224891,"avatar_url":"https://avatars.githubusercontent.com/u/7224891?v=3","gravatar_id":"","url":"https://api.github.com/users/openfun","html_url":"https://github.com/openfun","followers_url":"https://api.github.com/users/openfun/followers","following_url":"https://api.github.com/users/openfun/following{/other_user}","gists_url":"https://api.github.com/users/openfun/gists{/gist_id}","starred_url":"https://api.github.com/users/openfun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfun/subscriptions","organizations_url":"https://api.github.com/users/openfun/orgs","repos_url":"https://api.github.com/users/openfun/repos","events_url":"https://api.github.com/users/openfun/events{/privacy}","received_events_url":"https://api.github.com/users/openfun/received_events","type":"Organization","site_admin":false},"repo":{"id":38699576,"name":"edx-gea","full_name":"openfun/edx-gea","owner":{"login":"openfun","id":7224891,"avatar_url":"https://avatars.githubusercontent.com/u/7224891?v=3","gravatar_id":"","url":"https://api.github.com/users/openfun","html_url":"https://github.com/openfun","followers_url":"https://api.github.com/users/openfun/followers","following_url":"https://api.github.com/users/openfun/following{/other_user}","gists_url":"https://api.github.com/users/openfun/gists{/gist_id}","starred_url":"https://api.github.com/users/openfun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfun/subscriptions","organizations_url":"https://api.github.com/users/openfun/orgs","repos_url":"https://api.github.com/users/openfun/repos","events_url":"https://api.github.com/users/openfun/events{/privacy}","received_events_url":"https://api.github.com/users/openfun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openfun/edx-gea","description":"Grade external activity  xblock.","fork":false,"url":"https://api.github.com/repos/openfun/edx-gea","forks_url":"https://api.github.com/repos/openfun/edx-gea/forks","keys_url":"https://api.github.com/repos/openfun/edx-gea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openfun/edx-gea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openfun/edx-gea/teams","hooks_url":"https://api.github.com/repos/openfun/edx-gea/hooks","issue_events_url":"https://api.github.com/repos/openfun/edx-gea/issues/events{/number}","events_url":"https://api.github.com/repos/openfun/edx-gea/events","assignees_url":"https://api.github.com/repos/openfun/edx-gea/assignees{/user}","branches_url":"https://api.github.com/repos/openfun/edx-gea/branches{/branch}","tags_url":"https://api.github.com/repos/openfun/edx-gea/tags","blobs_url":"https://api.github.com/repos/openfun/edx-gea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openfun/edx-gea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openfun/edx-gea/git/refs{/sha}","trees_url":"https://api.github.com/repos/openfun/edx-gea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openfun/edx-gea/statuses/{sha}","languages_url":"https://api.github.com/repos/openfun/edx-gea/languages","stargazers_url":"https://api.github.com/repos/openfun/edx-gea/stargazers","contributors_url":"https://api.github.com/repos/openfun/edx-gea/contributors","subscribers_url":"https://api.github.com/repos/openfun/edx-gea/subscribers","subscription_url":"https://api.github.com/repos/openfun/edx-gea/subscription","commits_url":"https://api.github.com/repos/openfun/edx-gea/commits{/sha}","git_commits_url":"https://api.github.com/repos/openfun/edx-gea/git/commits{/sha}","comments_url":"https://api.github.com/repos/openfun/edx-gea/comments{/number}","issue_comment_url":"https://api.github.com/repos/openfun/edx-gea/issues/comments{/number}","contents_url":"https://api.github.com/repos/openfun/edx-gea/contents/{+path}","compare_url":"https://api.github.com/repos/openfun/edx-gea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openfun/edx-gea/merges","archive_url":"https://api.github.com/repos/openfun/edx-gea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openfun/edx-gea/downloads","issues_url":"https://api.github.com/repos/openfun/edx-gea/issues{/number}","pulls_url":"https://api.github.com/repos/openfun/edx-gea/pulls{/number}","milestones_url":"https://api.github.com/repos/openfun/edx-gea/milestones{/number}","notifications_url":"https://api.github.com/repos/openfun/edx-gea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openfun/edx-gea/labels{/name}","releases_url":"https://api.github.com/repos/openfun/edx-gea/releases{/id}","created_at":"2015-07-07T16:14:14Z","updated_at":"2015-07-07T16:26:57Z","pushed_at":"2015-07-21T11:57:31Z","git_url":"git://github.com/openfun/edx-gea.git","ssh_url":"git@github.com:openfun/edx-gea.git","clone_url":"https://github.com/openfun/edx-gea.git","svn_url":"https://github.com/openfun/edx-gea","homepage":"","size":180,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"openfun:master","ref":"master","sha":"d92f9b93a9925b2812359e5c07a7fc72ee9ac87e","user":{"login":"openfun","id":7224891,"avatar_url":"https://avatars.githubusercontent.com/u/7224891?v=3","gravatar_id":"","url":"https://api.github.com/users/openfun","html_url":"https://github.com/openfun","followers_url":"https://api.github.com/users/openfun/followers","following_url":"https://api.github.com/users/openfun/following{/other_user}","gists_url":"https://api.github.com/users/openfun/gists{/gist_id}","starred_url":"https://api.github.com/users/openfun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfun/subscriptions","organizations_url":"https://api.github.com/users/openfun/orgs","repos_url":"https://api.github.com/users/openfun/repos","events_url":"https://api.github.com/users/openfun/events{/privacy}","received_events_url":"https://api.github.com/users/openfun/received_events","type":"Organization","site_admin":false},"repo":{"id":38699576,"name":"edx-gea","full_name":"openfun/edx-gea","owner":{"login":"openfun","id":7224891,"avatar_url":"https://avatars.githubusercontent.com/u/7224891?v=3","gravatar_id":"","url":"https://api.github.com/users/openfun","html_url":"https://github.com/openfun","followers_url":"https://api.github.com/users/openfun/followers","following_url":"https://api.github.com/users/openfun/following{/other_user}","gists_url":"https://api.github.com/users/openfun/gists{/gist_id}","starred_url":"https://api.github.com/users/openfun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfun/subscriptions","organizations_url":"https://api.github.com/users/openfun/orgs","repos_url":"https://api.github.com/users/openfun/repos","events_url":"https://api.github.com/users/openfun/events{/privacy}","received_events_url":"https://api.github.com/users/openfun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openfun/edx-gea","description":"Grade external activity  xblock.","fork":false,"url":"https://api.github.com/repos/openfun/edx-gea","forks_url":"https://api.github.com/repos/openfun/edx-gea/forks","keys_url":"https://api.github.com/repos/openfun/edx-gea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openfun/edx-gea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openfun/edx-gea/teams","hooks_url":"https://api.github.com/repos/openfun/edx-gea/hooks","issue_events_url":"https://api.github.com/repos/openfun/edx-gea/issues/events{/number}","events_url":"https://api.github.com/repos/openfun/edx-gea/events","assignees_url":"https://api.github.com/repos/openfun/edx-gea/assignees{/user}","branches_url":"https://api.github.com/repos/openfun/edx-gea/branches{/branch}","tags_url":"https://api.github.com/repos/openfun/edx-gea/tags","blobs_url":"https://api.github.com/repos/openfun/edx-gea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openfun/edx-gea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openfun/edx-gea/git/refs{/sha}","trees_url":"https://api.github.com/repos/openfun/edx-gea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openfun/edx-gea/statuses/{sha}","languages_url":"https://api.github.com/repos/openfun/edx-gea/languages","stargazers_url":"https://api.github.com/repos/openfun/edx-gea/stargazers","contributors_url":"https://api.github.com/repos/openfun/edx-gea/contributors","subscribers_url":"https://api.github.com/repos/openfun/edx-gea/subscribers","subscription_url":"https://api.github.com/repos/openfun/edx-gea/subscription","commits_url":"https://api.github.com/repos/openfun/edx-gea/commits{/sha}","git_commits_url":"https://api.github.com/repos/openfun/edx-gea/git/commits{/sha}","comments_url":"https://api.github.com/repos/openfun/edx-gea/comments{/number}","issue_comment_url":"https://api.github.com/repos/openfun/edx-gea/issues/comments{/number}","contents_url":"https://api.github.com/repos/openfun/edx-gea/contents/{+path}","compare_url":"https://api.github.com/repos/openfun/edx-gea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openfun/edx-gea/merges","archive_url":"https://api.github.com/repos/openfun/edx-gea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openfun/edx-gea/downloads","issues_url":"https://api.github.com/repos/openfun/edx-gea/issues{/number}","pulls_url":"https://api.github.com/repos/openfun/edx-gea/pulls{/number}","milestones_url":"https://api.github.com/repos/openfun/edx-gea/milestones{/number}","notifications_url":"https://api.github.com/repos/openfun/edx-gea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openfun/edx-gea/labels{/name}","releases_url":"https://api.github.com/repos/openfun/edx-gea/releases{/id}","created_at":"2015-07-07T16:14:14Z","updated_at":"2015-07-07T16:26:57Z","pushed_at":"2015-07-21T11:57:31Z","git_url":"git://github.com/openfun/edx-gea.git","ssh_url":"git@github.com:openfun/edx-gea.git","clone_url":"https://github.com/openfun/edx-gea.git","svn_url":"https://github.com/openfun/edx-gea","homepage":"","size":180,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/1"},"html":{"href":"https://github.com/openfun/edx-gea/pull/1"},"issue":{"href":"https://api.github.com/repos/openfun/edx-gea/issues/1"},"comments":{"href":"https://api.github.com/repos/openfun/edx-gea/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openfun/edx-gea/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/openfun/edx-gea/statuses/86c1cda1a3b792ea5ae5c3f2847bb9c3c8995e91"}}}}