{"action":"created","comment":{"url":"https://api.github.com/repos/edx/course-discovery/pulls/comments/151694704","pull_request_review_id":77446016,"id":151694704,"diff_hunk":"@@ -570,6 +570,51 @@ def test_one_click_purchase_eligible(self):\n         )\n         self.assertTrue(program.is_program_eligible_for_one_click_purchase)\n \n+    def test_one_click_purchase_eligible_with_entitlements(self):\n+        \"\"\" Verify that program is one click purchase eligible when its courses have unexpired entitlement products. \"\"\"\n+        verified_seat_type, __ = SeatType.objects.get_or_create(name=Seat.VERIFIED)\n+        program_type = factories.ProgramTypeFactory(applicable_seat_types=[verified_seat_type])\n+\n+        # Program has one_click_purchase_enabled set to True,\n+        # all courses have a verified mode entitlement product and multiple course runs.\n+        courses = []\n+        for __ in range(3):\n+            entitlement = factories.CourseEntitlementFactory(mode=verified_seat_type, expires=None)\n+            for __ in range(3):\n+                factories.SeatFactory(\n+                    course_run=factories.CourseRunFactory(\n+                        end=None,\n+                        enrollment_end=None,\n+                        course=entitlement.course\n+                    ),\n+                    type=Seat.VERIFIED, upgrade_deadline=None\n+                )\n+            courses.append(entitlement.course)\n+\n+        program = factories.ProgramFactory(\n+            courses=courses,\n+            one_click_purchase_enabled=True,\n+            type=program_type,\n+        )\n+        self.assertTrue(program.is_program_eligible_for_one_click_purchase)\n+\n+        # One of the courses has an expired entitlement\n+        expired_entitlement = courses[2].entitlements.first()\n+        expired_entitlement.expires = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=7)\n+        expired_entitlement.save()\n+        self.assertFalse(program.is_program_eligible_for_one_click_purchase)\n+\n+        # There is only one course run for the course having an expired entitlement","path":"course_discovery/apps/course_metadata/tests/test_models.py","position":38,"original_position":38,"commit_id":"cf3e48761e8d087331f1a05e567277bd1ba8eaaf","original_commit_id":"cf3e48761e8d087331f1a05e567277bd1ba8eaaf","user":{"login":"mjfrey","id":2236013,"avatar_url":"https://avatars0.githubusercontent.com/u/2236013?v=4","gravatar_id":"","url":"https://api.github.com/users/mjfrey","html_url":"https://github.com/mjfrey","followers_url":"https://api.github.com/users/mjfrey/followers","following_url":"https://api.github.com/users/mjfrey/following{/other_user}","gists_url":"https://api.github.com/users/mjfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/mjfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjfrey/subscriptions","organizations_url":"https://api.github.com/users/mjfrey/orgs","repos_url":"https://api.github.com/users/mjfrey/repos","events_url":"https://api.github.com/users/mjfrey/events{/privacy}","received_events_url":"https://api.github.com/users/mjfrey/received_events","type":"User","site_admin":false},"body":"Is this supposed to be a test?","created_at":"2017-11-17T14:19:19Z","updated_at":"2017-11-17T14:20:27Z","html_url":"https://github.com/edx/course-discovery/pull/1226#discussion_r151694704","pull_request_url":"https://api.github.com/repos/edx/course-discovery/pulls/1226","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/comments/151694704"},"html":{"href":"https://github.com/edx/course-discovery/pull/1226#discussion_r151694704"},"pull_request":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1226"}}},"pull_request":{"url":"https://api.github.com/repos/edx/course-discovery/pulls/1226","id":153305300,"html_url":"https://github.com/edx/course-discovery/pull/1226","diff_url":"https://github.com/edx/course-discovery/pull/1226.diff","patch_url":"https://github.com/edx/course-discovery/pull/1226.patch","issue_url":"https://api.github.com/repos/edx/course-discovery/issues/1226","number":1226,"state":"open","locked":false,"title":"Update one-click purchase eligibility logic to consider entitlements","user":{"login":"McKenzieW","id":10751012,"avatar_url":"https://avatars2.githubusercontent.com/u/10751012?v=4","gravatar_id":"","url":"https://api.github.com/users/McKenzieW","html_url":"https://github.com/McKenzieW","followers_url":"https://api.github.com/users/McKenzieW/followers","following_url":"https://api.github.com/users/McKenzieW/following{/other_user}","gists_url":"https://api.github.com/users/McKenzieW/gists{/gist_id}","starred_url":"https://api.github.com/users/McKenzieW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/McKenzieW/subscriptions","organizations_url":"https://api.github.com/users/McKenzieW/orgs","repos_url":"https://api.github.com/users/McKenzieW/repos","events_url":"https://api.github.com/users/McKenzieW/events{/privacy}","received_events_url":"https://api.github.com/users/McKenzieW/received_events","type":"User","site_admin":false},"body":"A program is eligible for one-click purchase if, for each course in a program, if it has either an unexpired entitlement product with an applicable mode or exactly one published course run with an applicably-typed seat product.\r\n\r\n[LEARNER-3254](https://openedx.atlassian.net/browse/LEARNER-3254)","created_at":"2017-11-17T14:06:07Z","updated_at":"2017-11-17T14:20:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc46f84120d09e95d8db6e19a460c99dd04d5082","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/course-discovery/pulls/1226/commits","review_comments_url":"https://api.github.com/repos/edx/course-discovery/pulls/1226/comments","review_comment_url":"https://api.github.com/repos/edx/course-discovery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/course-discovery/issues/1226/comments","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/cf3e48761e8d087331f1a05e567277bd1ba8eaaf","head":{"label":"edx:McKenzieW/learner-3254","ref":"McKenzieW/learner-3254","sha":"cf3e48761e8d087331f1a05e567277bd1ba8eaaf","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":45866355,"name":"course-discovery","full_name":"edx/course-discovery","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/course-discovery","description":"Service providing access to consolidated course and program metadata","fork":false,"url":"https://api.github.com/repos/edx/course-discovery","forks_url":"https://api.github.com/repos/edx/course-discovery/forks","keys_url":"https://api.github.com/repos/edx/course-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/course-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/course-discovery/teams","hooks_url":"https://api.github.com/repos/edx/course-discovery/hooks","issue_events_url":"https://api.github.com/repos/edx/course-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/edx/course-discovery/events","assignees_url":"https://api.github.com/repos/edx/course-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/edx/course-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/edx/course-discovery/tags","blobs_url":"https://api.github.com/repos/edx/course-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/course-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/course-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/course-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/course-discovery/languages","stargazers_url":"https://api.github.com/repos/edx/course-discovery/stargazers","contributors_url":"https://api.github.com/repos/edx/course-discovery/contributors","subscribers_url":"https://api.github.com/repos/edx/course-discovery/subscribers","subscription_url":"https://api.github.com/repos/edx/course-discovery/subscription","commits_url":"https://api.github.com/repos/edx/course-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/course-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/course-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/course-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/course-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/edx/course-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/course-discovery/merges","archive_url":"https://api.github.com/repos/edx/course-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/course-discovery/downloads","issues_url":"https://api.github.com/repos/edx/course-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/edx/course-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/course-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/course-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/course-discovery/labels{/name}","releases_url":"https://api.github.com/repos/edx/course-discovery/releases{/id}","deployments_url":"https://api.github.com/repos/edx/course-discovery/deployments","created_at":"2015-11-09T20:57:54Z","updated_at":"2017-09-06T00:04:50Z","pushed_at":"2017-11-17T14:10:37Z","git_url":"git://github.com/edx/course-discovery.git","ssh_url":"git@github.com:edx/course-discovery.git","clone_url":"https://github.com/edx/course-discovery.git","svn_url":"https://github.com/edx/course-discovery","homepage":"","size":13381,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":10,"forks":10,"open_issues":10,"watchers":15,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"c71aeeb06355e278a273aa07a51aba57bc708387","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":45866355,"name":"course-discovery","full_name":"edx/course-discovery","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/course-discovery","description":"Service providing access to consolidated course and program metadata","fork":false,"url":"https://api.github.com/repos/edx/course-discovery","forks_url":"https://api.github.com/repos/edx/course-discovery/forks","keys_url":"https://api.github.com/repos/edx/course-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/course-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/course-discovery/teams","hooks_url":"https://api.github.com/repos/edx/course-discovery/hooks","issue_events_url":"https://api.github.com/repos/edx/course-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/edx/course-discovery/events","assignees_url":"https://api.github.com/repos/edx/course-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/edx/course-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/edx/course-discovery/tags","blobs_url":"https://api.github.com/repos/edx/course-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/course-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/course-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/course-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/course-discovery/languages","stargazers_url":"https://api.github.com/repos/edx/course-discovery/stargazers","contributors_url":"https://api.github.com/repos/edx/course-discovery/contributors","subscribers_url":"https://api.github.com/repos/edx/course-discovery/subscribers","subscription_url":"https://api.github.com/repos/edx/course-discovery/subscription","commits_url":"https://api.github.com/repos/edx/course-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/course-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/course-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/course-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/course-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/edx/course-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/course-discovery/merges","archive_url":"https://api.github.com/repos/edx/course-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/course-discovery/downloads","issues_url":"https://api.github.com/repos/edx/course-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/edx/course-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/course-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/course-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/course-discovery/labels{/name}","releases_url":"https://api.github.com/repos/edx/course-discovery/releases{/id}","deployments_url":"https://api.github.com/repos/edx/course-discovery/deployments","created_at":"2015-11-09T20:57:54Z","updated_at":"2017-09-06T00:04:50Z","pushed_at":"2017-11-17T14:10:37Z","git_url":"git://github.com/edx/course-discovery.git","ssh_url":"git@github.com:edx/course-discovery.git","clone_url":"https://github.com/edx/course-discovery.git","svn_url":"https://github.com/edx/course-discovery","homepage":"","size":13381,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":10,"forks":10,"open_issues":10,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1226"},"html":{"href":"https://github.com/edx/course-discovery/pull/1226"},"issue":{"href":"https://api.github.com/repos/edx/course-discovery/issues/1226"},"comments":{"href":"https://api.github.com/repos/edx/course-discovery/issues/1226/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1226/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1226/commits"},"statuses":{"href":"https://api.github.com/repos/edx/course-discovery/statuses/cf3e48761e8d087331f1a05e567277bd1ba8eaaf"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mjfrey"}}