def test_save_metadata_list_with_mismatched_asset(self, storebuilder):
        """
        Save a list of asset metadata all at once - but with one asset's metadata from a different course.
        """
        # pylint: disable=bad-continuation
        with storebuilder.build() as (__, store):
            course1 = CourseFactory.create(modulestore=store)
            course2 = CourseFactory.create(modulestore=store)

            # Make a list of AssetMetadata objects.
            md_list = []
            for asset_type, filename in self.alls:
                if asset_type == "asset":
                    asset_key = course2.id.make_asset_key(asset_type, filename)
                else:
                    asset_key = course1.id.make_asset_key(asset_type, filename)
                md_list.append(self._make_asset_thumbnail_metadata(self._make_asset_metadata(asset_key)))

            # Save 'em.
            store.save_asset_metadata_list(md_list, ModuleStoreEnum.UserID.test)

            # Check 'em.
            for asset_type, asset_list in (("different", self.differents), ("vrml", self.vrmls)):
                assets = store.get_all_asset_metadata(course1.id, asset_type)
                self.assertEquals(len(assets), len(asset_list))
                self._check_asset_values(assets, asset_list)

            self.assertEquals(len(store.get_all_asset_metadata(course1.id, "asset")), 0)
            self.assertEquals(len(store.get_all_asset_metadata(course1.id, None)), 3)

            assets = store.get_all_asset_metadata(
                course1.id, None, start=0, maxresults=-1, sort=("displayname", ModuleStoreEnum.SortOrder.ascending)
            )
            self.assertEquals(len(assets), len(self.differents + self.vrmls))
            self._check_asset_values(assets, self.differents + self.vrmls)
Example #2
0
    def test_courseware_page_unfulfilled_prereqs(self):
        """
        Test courseware access when a course has pre-requisite course yet to be completed
        """
        seed_milestone_relationship_types()
        pre_requisite_course = CourseFactory.create(org="edX", course="900", run="test_run")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org="edX", course="1000", run="test_run", pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        test_password = "t3stp4ss.!"
        user = UserFactory.create()
        user.set_password(test_password)
        user.save()
        self.login(user.email, test_password)
        CourseEnrollmentFactory(user=user, course_id=course.id)

        url = reverse("courseware", args=[unicode(course.id)])
        response = self.client.get(url)
        self.assertRedirects(response, reverse("dashboard"))
        self.assertEqual(response.status_code, 302)

        fulfill_course_milestone(pre_requisite_course.id, user)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
Example #3
0
    def test_refund_cert_callback_before_expiration_email(self):
        """ Test that refund emails are being sent correctly. """
        course_id = "refund_before_expiration/test/one"
        many_days = datetime.timedelta(days=60)

        CourseFactory.create(org="refund_before_expiration", number="test", run="course", display_name="one")
        course_mode = CourseMode(
            course_id=course_id,
            mode_slug="verified",
            mode_display_name="verified cert",
            min_price=self.cost,
            expiration_datetime=datetime.datetime.now(pytz.utc) + many_days,
        )
        course_mode.save()

        CourseEnrollment.enroll(self.user, course_id, "verified")
        cart = Order.get_cart_for_user(user=self.user)
        CertificateItem.add_to_order(cart, course_id, self.cost, "verified")
        cart.purchase()

        mail.outbox = []
        with patch("shoppingcart.models.log.error") as mock_error_logger:
            CourseEnrollment.unenroll(self.user, course_id)
            self.assertFalse(mock_error_logger.called)
            self.assertEquals(len(mail.outbox), 1)
            self.assertEquals("[Refund] User-Requested Refund", mail.outbox[0].subject)
            self.assertEquals(settings.PAYMENT_SUPPORT_EMAIL, mail.outbox[0].from_email)
            self.assertIn("has requested a refund on Order", mail.outbox[0].body)
Example #4
0
    def setUp(self):
        super(OrganizationsApiTests, self).setUp()
        self.test_server_prefix = "https://testserver"
        self.base_organizations_uri = "/api/server/organizations/"
        self.base_users_uri = "/api/server/users"
        self.base_groups_uri = "/api/server/groups"
        self.test_organization_name = str(uuid.uuid4())
        self.test_organization_display_name = "Test Org"
        self.test_organization_contact_name = "John Org"
        self.test_organization_contact_email = "john@test.org"
        self.test_organization_contact_phone = "+1 332 232 24234"
        self.test_organization_logo_url = "org_logo.jpg"

        self.test_user_email = str(uuid.uuid4())
        self.test_user_username = str(uuid.uuid4())
        self.test_user = User.objects.create(email=self.test_user_email, username=self.test_user_username)
        profile = UserProfile(user=self.test_user)
        profile.city = "Boston"
        profile.save()

        self.test_user2 = User.objects.create(email=str(uuid.uuid4()), username=str(uuid.uuid4()))
        profile2 = UserProfile(user=self.test_user2)
        profile2.city = "NYC"
        profile2.save()

        self.course = CourseFactory.create()
        self.second_course = CourseFactory.create(number="899")

        self.client = SecureClient()
        cache.clear()
Example #5
0
 def setUp(self):
     super(IndexPageCourseCardsSortingTests, self).setUp()
     self.starting_later = CourseFactory.create(
         org="MITx",
         number="1000",
         display_name="Starting later, Announced later",
         metadata={
             "start": datetime.datetime.now(UTC) + datetime.timedelta(days=4),
             "announcement": datetime.datetime.now(UTC) + datetime.timedelta(days=3),
         },
         emit_signals=True,
     )
     self.starting_earlier = CourseFactory.create(
         org="MITx",
         number="1001",
         display_name="Starting earlier, Announced earlier",
         metadata={
             "start": datetime.datetime.now(UTC) + datetime.timedelta(days=2),
             "announcement": datetime.datetime.now(UTC) + datetime.timedelta(days=1),
         },
         emit_signals=True,
     )
     self.course_with_default_start_date = CourseFactory.create(
         org="MITx", number="1002", display_name="Tech Beta Course", emit_signals=True
     )
     self.factory = RequestFactory()
    def build_courses(self):
        """
        Build up a course tree with multiple test courses
        """

        self.courses = [
            CourseFactory.create(
                org="ElasticsearchFiltering",
                course="ES101F",
                run="test_run",
                display_name="Elasticsearch Filtering test course",
            ),
            CourseFactory.create(
                org="FilterTest", course="FT101", run="test_run", display_name="FilterTest test course"
            ),
        ]

        self.chapter = ItemFactory.create(
            parent_location=self.courses[0].location, category="chapter", display_name="Week 1", publish_item=True
        )

        self.chapter2 = ItemFactory.create(
            parent_location=self.courses[1].location, category="chapter", display_name="Week 1", publish_item=True
        )

        self.groups = [Group(1, "Group 1"), Group(2, "Group 2")]

        self.content_groups = [1, 2]
Example #7
0
 def setUp(self):
     self.user = UserFactory.create()
     course = CourseFactory.create(org="org", number="test", display_name="Test Course")
     self.course_key = course.id
     for i in xrange(1, 5):
         CourseFactory.create(org="org", number="test", display_name="Test Course {0}".format(i))
     self.cost = 40
Example #8
0
    def test_course_with_prereq(self):
        """
        Simulate having a course which has closed enrollments that has
        a pre-req course
        """
        pre_requisite_course = CourseFactory.create(org="edX", course="900", display_name="pre requisite course")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]

        # for this failure to occur, the enrollment window needs to be in the past
        course = CourseFactory.create(
            org="edX",
            course="1000",
            display_name="course that has pre requisite",
            # closed enrollment
            enrollment_start=datetime.datetime(2013, 1, 1),
            enrollment_end=datetime.datetime(2014, 1, 1),
            start=datetime.datetime(2013, 1, 1),
            end=datetime.datetime(2030, 1, 1),
            pre_requisite_courses=pre_requisite_courses,
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        resp = self.client.get("/")
        self.assertEqual(resp.status_code, 200)

        # make sure both courses are visible in the catalog
        self.assertIn("pre requisite course", resp.content)
        self.assertIn("course that has pre requisite", resp.content)
Example #9
0
    def create_test_data(self):
        self.invalid_course_id = "foo/bar/baz"
        self.course = CourseFactory.create(
            display_name="An Introduction to API Testing",
            raw_grader=[
                {"min_count": 24, "weight": 0.2, "type": "Homework", "drop_count": 0, "short_label": "HW"},
                {"min_count": 4, "weight": 0.8, "type": "Exam", "drop_count": 0, "short_label": "Exam"},
            ],
        )
        self.course_id = unicode(self.course.id)

        sequential = ItemFactory.create(
            category="sequential",
            parent_location=self.course.location,
            display_name="Lesson 1",
            format="Homework",
            graded=True,
        )

        ItemFactory.create(
            category="problem", parent_location=sequential.location, display_name="Problem 1", format="Homework"
        )

        self.empty_course = CourseFactory.create(
            start=datetime(2014, 6, 16, 14, 30),
            end=datetime(2015, 1, 16),
            org="MTD",
            # Use mongo so that we can get a test with a SlashSeparatedCourseKey
            default_store=ModuleStoreEnum.Type.mongo,
        )
    def setUp(self):

        self.course = CourseFactory.create(number="999", display_name="Robot_Super_Course")
        self.overview_chapter = ItemFactory.create(display_name="Overview")
        self.courseware_chapter = ItemFactory.create(display_name="courseware")

        self.test_course = CourseFactory.create(number="666", display_name="Robot_Sub_Course")
        self.other_org_course = CourseFactory.create(org="Other_Org_Course")
        self.sub_courseware_chapter = ItemFactory.create(
            parent_location=self.test_course.location, display_name="courseware"
        )
        self.sub_overview_chapter = ItemFactory.create(
            parent_location=self.sub_courseware_chapter.location, display_name="Overview"
        )
        self.welcome_section = ItemFactory.create(
            parent_location=self.overview_chapter.location, display_name="Welcome"
        )

        self.global_staff_user = GlobalStaffFactory()
        self.unenrolled_user = UserFactory(last_name="Unenrolled")

        self.enrolled_user = UserFactory(last_name="Enrolled")
        CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.course.id)
        CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.test_course.id)

        self.staff_user = StaffFactory(course=self.course.location)
        self.instructor_user = InstructorFactory(course=self.course.location)
        self.org_staff_user = OrgStaffFactory(course=self.course.location)
        self.org_instructor_user = OrgInstructorFactory(course=self.course.location)
Example #11
0
    def setUp(self):
        super(AboutTestCase, self).setUp()
        self.course = CourseFactory.create()
        self.about = ItemFactory.create(
            category="about", parent_location=self.course.location, data="OOGIE BLOOGIE", display_name="overview"
        )
        self.course_without_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_NONE)
        self.about = ItemFactory.create(
            category="about",
            parent_location=self.course_without_about.location,
            data="WITHOUT ABOUT",
            display_name="overview",
        )
        self.course_with_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_ABOUT)
        self.about = ItemFactory.create(
            category="about",
            parent_location=self.course_with_about.location,
            data="WITH ABOUT",
            display_name="overview",
        )

        self.purchase_course = CourseFactory.create(org="MITx", number="buyme", display_name="Course To Buy")
        self.course_mode = CourseMode(
            course_id=self.purchase_course.id, mode_slug="honor", mode_display_name="honor cert", min_price=10
        )
        self.course_mode.save()
Example #12
0
    def setUp(self):
        super(TestNavigation, self).setUp()
        self.test_course = CourseFactory.create()
        self.course = CourseFactory.create()
        self.chapter0 = ItemFactory.create(parent=self.course, display_name="Overview")
        self.chapter9 = ItemFactory.create(parent=self.course, display_name="factory_chapter")
        self.section0 = ItemFactory.create(parent=self.chapter0, display_name="Welcome")
        self.section9 = ItemFactory.create(parent=self.chapter9, display_name="factory_section")
        self.unit0 = ItemFactory.create(parent=self.section0, display_name="New Unit")

        self.chapterchrome = ItemFactory.create(parent=self.course, display_name="Chrome")
        self.chromelesssection = ItemFactory.create(parent=self.chapterchrome, display_name="chromeless", chrome="none")
        self.accordionsection = ItemFactory.create(
            parent=self.chapterchrome, display_name="accordion", chrome="accordion"
        )
        self.tabssection = ItemFactory.create(parent=self.chapterchrome, display_name="tabs", chrome="tabs")
        self.defaultchromesection = ItemFactory.create(parent=self.chapterchrome, display_name="defaultchrome")
        self.fullchromesection = ItemFactory.create(
            parent=self.chapterchrome, display_name="fullchrome", chrome="accordion,tabs"
        )
        self.tabtest = ItemFactory.create(
            parent=self.chapterchrome, display_name="progress_tab", default_tab="progress"
        )

        # Create student accounts and activate them.
        for i in range(len(self.STUDENT_INFO)):
            email, password = self.STUDENT_INFO[i]
            username = "u{0}".format(i)
            self.create_account(username, email, password)
            self.activate_user(email)

        self.staff_user = GlobalStaffFactory()
    def test_refund_cert_callback_before_expiration(self):
        # If the expiration date has not yet passed on a verified mode, the user can be refunded
        course_id = "refund_before_expiration/test/one"
        many_days = datetime.timedelta(days=60)

        CourseFactory.create(org="refund_before_expiration", number="test", run="course", display_name="one")
        course_mode = CourseMode(
            course_id=course_id,
            mode_slug="verified",
            mode_display_name="verified cert",
            min_price=self.cost,
            expiration_datetime=(datetime.datetime.now(pytz.utc) + many_days),
        )
        course_mode.save()

        CourseEnrollment.enroll(self.user, course_id, "verified")
        cart = Order.get_cart_for_user(user=self.user)
        CertificateItem.add_to_order(cart, course_id, self.cost, "verified")
        cart.purchase()

        CourseEnrollment.unenroll(self.user, course_id)
        target_certs = CertificateItem.objects.filter(
            course_id=course_id, user_id=self.user, status="refunded", mode="verified"
        )
        self.assertTrue(target_certs[0])
        self.assertTrue(target_certs[0].refund_requested_time)
        self.assertEquals(target_certs[0].order.status, "refunded")
 def test_course_index_view_with_course(self):
     """Test viewing the index page with an existing course"""
     CourseFactory.create(display_name="Robot Super Educational Course")
     resp = self.client.get(reverse("index"))
     self.assertContains(
         resp, '<span class="class-name">Robot Super Educational Course</span>', status_code=200, html=True
     )
    def setUp(self):
        super(MigrateCourseIdsTests, self).setUp()
        self.course = CourseFactory.create(start=datetime(2014, 6, 16, 14, 30), end=datetime(2015, 1, 16))
        self.test_data = "<html>{}</html>".format(str(uuid.uuid4()))

        self.chapter = ItemFactory.create(
            category="chapter",
            parent_location=self.course.location,
            data=self.test_data,
            due=datetime(2014, 5, 16, 14, 30),
            display_name="Overview",
        )

        self.old_style_course_id = self.course.id.to_deprecated_string()
        self.new_style_course_id = unicode(self.course.id)
        self.old_style_content_id = self.chapter.location.to_deprecated_string()
        self.new_style_content_id = unicode(self.chapter.location)

        self.course2 = CourseFactory.create(org="TEST", start=datetime(2014, 6, 16, 14, 30), end=datetime(2015, 1, 16))
        self.chapter2 = ItemFactory.create(
            category="chapter",
            parent_location=self.course2.location,
            data=self.test_data,
            due=datetime(2014, 5, 16, 14, 30),
            display_name="Overview",
        )

        self.new_style_course_id2 = unicode(self.course2.id)
        self.new_style_content_id2 = unicode(self.chapter2.location)
 def setUp(self):
     self.user = UserFactory.create()
     self.course_id = "org/test/Test_Course"
     CourseFactory.create(org="org", number="test", display_name="Test Course")
     for i in xrange(1, 5):
         CourseFactory.create(org="org", number="test", display_name="Test Course {0}".format(i))
     self.cost = 40
Example #17
0
    def test_courseware_access(self):
        self.login()

        course_with_prereq = CourseFactory.create(start=self.LAST_WEEK, mobile_available=True)
        prerequisite_course = CourseFactory.create()
        set_prerequisite_courses(course_with_prereq.id, [unicode(prerequisite_course.id)])

        # Create list of courses with various expected courseware_access responses and corresponding expected codes
        courses = [
            course_with_prereq,
            CourseFactory.create(start=self.NEXT_WEEK, mobile_available=True),
            CourseFactory.create(visible_to_staff_only=True, mobile_available=True),
            CourseFactory.create(start=self.LAST_WEEK, mobile_available=True, visible_to_staff_only=False),
        ]

        expected_error_codes = [
            MilestoneError().error_code,  # 'unfulfilled_milestones'
            StartDateError(self.NEXT_WEEK).error_code,  # 'course_not_started'
            VisibilityError().error_code,  # 'not_visible_to_user'
            None,
        ]

        # Enroll in all the courses
        for course in courses:
            self.enroll(course.id)

        # Verify courses have the correct response through error code. Last enrolled course is first course in response
        response = self.api_response()
        for course_index in range(len(courses)):
            result = response.data[course_index]["course"]["courseware_access"]
            self.assertEqual(result["error_code"], expected_error_codes[::-1][course_index])

            if result["error_code"] is not None:
                self.assertFalse(result["has_access"])
Example #18
0
    def test_access_on_course_with_pre_requisites(self):
        """
        Test course access when a course has pre-requisite course yet to be completed
        """
        seed_milestone_relationship_types()
        user = UserFactory.create()

        pre_requisite_course = CourseFactory.create(org="test_org", number="788", run="test_run")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org="test_org", number="786", run="test_run", pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        # user should not be able to load course even if enrolled
        CourseEnrollmentFactory(user=user, course_id=course.id)
        response = access._has_access_course_desc(user, "view_courseware_with_prerequisites", course)
        self.assertFalse(response)
        self.assertIsInstance(response, access_response.MilestoneError)
        # Staff can always access course
        staff = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course_desc(staff, "view_courseware_with_prerequisites", course))

        # User should be able access after completing required course
        fulfill_course_milestone(pre_requisite_course.id, user)
        self.assertTrue(access._has_access_course_desc(user, "view_courseware_with_prerequisites", course))
Example #19
0
    def setUpClass(cls):
        super(TestMicrosites, cls).setUpClass()
        cls.course = CourseFactory.create(display_name="Robot_Super_Course", org="TestMicrositeX", emit_signals=True)
        cls.chapter0 = ItemFactory.create(parent_location=cls.course.location, display_name="Overview")
        cls.chapter9 = ItemFactory.create(parent_location=cls.course.location, display_name="factory_chapter")
        cls.section0 = ItemFactory.create(parent_location=cls.chapter0.location, display_name="Welcome")
        cls.section9 = ItemFactory.create(parent_location=cls.chapter9.location, display_name="factory_section")

        cls.course_outside_microsite = CourseFactory.create(
            display_name="Robot_Course_Outside_Microsite", org="FooX", emit_signals=True
        )

        # have a course which explicitly sets visibility in catalog to False
        cls.course_hidden_visibility = CourseFactory.create(
            display_name="Hidden_course",
            org="TestMicrositeX",
            catalog_visibility=CATALOG_VISIBILITY_NONE,
            emit_signals=True,
        )

        # have a course which explicitly sets visibility in catalog and about to true
        cls.course_with_visibility = CourseFactory.create(
            display_name="visible_course",
            org="TestMicrositeX",
            course="foo",
            catalog_visibility=CATALOG_VISIBILITY_CATALOG_AND_ABOUT,
            emit_signals=True,
        )
    def setUp(self):
        super(TestMicrosites, self).setUp()

        # use a different hostname to test Microsites since they are
        # triggered on subdomain mappings
        #
        # NOTE: The Microsite Configuration is in lms/envs/test.py. The content for the Test Microsite is in
        # test_microsites/test_microsite.
        #
        # IMPORTANT: For these tests to work, this domain must be defined via
        # DNS configuration (either local or published)

        self.course = CourseFactory.create(display_name="Robot_Super_Course", org="TestMicrositeX")
        self.chapter0 = ItemFactory.create(parent_location=self.course.location, display_name="Overview")
        self.chapter9 = ItemFactory.create(parent_location=self.course.location, display_name="factory_chapter")
        self.section0 = ItemFactory.create(parent_location=self.chapter0.location, display_name="Welcome")
        self.section9 = ItemFactory.create(parent_location=self.chapter9.location, display_name="factory_section")

        self.course_outside_microsite = CourseFactory.create(display_name="Robot_Course_Outside_Microsite", org="FooX")

        # have a course which explicitly sets visibility in catalog to False
        self.course_hidden_visibility = CourseFactory.create(
            display_name="Hidden_course", org="TestMicrositeX", catalog_visibility=CATALOG_VISIBILITY_NONE
        )

        # have a course which explicitly sets visibility in catalog and about to true
        self.course_with_visibility = CourseFactory.create(
            display_name="visible_course",
            org="TestMicrositeX",
            course="foo",
            catalog_visibility=CATALOG_VISIBILITY_CATALOG_AND_ABOUT,
        )
Example #21
0
    def setUp(self):
        """
        Set up courses and enrollments.
        """
        super(TestStudentDashboardWithCCX, self).setUp()

        # Create a Draft Mongo and a Split Mongo course and enroll a student user in them.
        self.student_password = "foobar"
        self.student = UserFactory.create(username="test", password=self.student_password, is_staff=False)
        self.draft_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.mongo)
        self.split_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
        CourseEnrollment.enroll(self.student, self.draft_course.id)
        CourseEnrollment.enroll(self.student, self.split_course.id)

        # Create a CCX coach.
        self.coach = AdminFactory.create()
        role = CourseCcxCoachRole(self.split_course.id)
        role.add_users(self.coach)

        # Create a CCX course and enroll the user in it.
        self.ccx = CcxFactory(course_id=self.split_course.id, coach=self.coach)
        last_week = datetime.datetime.now(UTC()) - datetime.timedelta(days=7)
        override_field_for_ccx(self.ccx, self.split_course, "start", last_week)  # Required by self.ccx.has_started().
        course_key = CCXLocator.from_course_locator(self.split_course.id, self.ccx.id)
        CourseEnrollment.enroll(self.student, course_key)
Example #22
0
    def setUp(self):
        patcher = patch("student.models.tracker")
        self.mock_tracker = patcher.start()
        self.user = UserFactory.create()
        self.user.set_password("password")
        self.user.save()
        self.instructor = AdminFactory.create()
        self.cost = 40
        self.coupon_code = "abcde"
        self.reg_code = "qwerty"
        self.percentage_discount = 10
        self.course = CourseFactory.create(org="MITx", number="999", display_name="Robot Super Course")
        self.course_key = self.course.id
        self.course_mode = CourseMode(
            course_id=self.course_key, mode_slug="honor", mode_display_name="honor cert", min_price=self.cost
        )
        self.course_mode.save()

        # Saving another testing course mode
        self.testing_cost = 20
        self.testing_course = CourseFactory.create(org="edX", number="888", display_name="Testing Super Course")
        self.testing_course_mode = CourseMode(
            course_id=self.testing_course.id,
            mode_slug="honor",
            mode_display_name="testing honor cert",
            min_price=self.testing_cost,
        )
        self.testing_course_mode.save()

        verified_course = CourseFactory.create(org="org", number="test", display_name="Test Course")
        self.verified_course_key = verified_course.id
        self.cart = Order.get_cart_for_user(self.user)
        self.addCleanup(patcher.stop)
Example #23
0
 def setUpClass(cls):
     super(CertificateGetTests, cls).setUpClass()
     cls.student = UserFactory()
     cls.student_no_cert = UserFactory()
     cls.uuid = uuid.uuid4().hex
     cls.web_cert_course = CourseFactory.create(
         org="edx", number="verified_1", display_name="Verified Course 1", cert_html_view_enabled=True
     )
     cls.pdf_cert_course = CourseFactory.create(
         org="edx", number="verified_2", display_name="Verified Course 2", cert_html_view_enabled=False
     )
     # certificate for the first course
     GeneratedCertificateFactory.create(
         user=cls.student,
         course_id=cls.web_cert_course.id,
         status=CertificateStatuses.downloadable,
         mode="verified",
         download_url="www.google.com",
         grade="0.88",
         verify_uuid=cls.uuid,
     )
     # certificate for the second course
     GeneratedCertificateFactory.create(
         user=cls.student,
         course_id=cls.pdf_cert_course.id,
         status=CertificateStatuses.downloadable,
         mode="honor",
         download_url="www.gmail.com",
         grade="0.99",
         verify_uuid=cls.uuid,
     )
    def test_pre_requisite_course_update_and_fetch(self):
        seed_milestone_relationship_types()
        url = get_url(self.course.id)
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        # assert pre_requisite_courses is initialized
        self.assertEqual([], course_detail_json["pre_requisite_courses"])

        # update pre requisite courses with a new course keys
        pre_requisite_course = CourseFactory.create(org="edX", course="900", run="test_run")
        pre_requisite_course2 = CourseFactory.create(org="edX", course="902", run="test_run")
        pre_requisite_course_keys = [unicode(pre_requisite_course.id), unicode(pre_requisite_course2.id)]
        course_detail_json["pre_requisite_courses"] = pre_requisite_course_keys
        self.client.ajax_post(url, course_detail_json)

        # fetch updated course to assert pre_requisite_courses has new values
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        self.assertEqual(pre_requisite_course_keys, course_detail_json["pre_requisite_courses"])

        # remove pre requisite course
        course_detail_json["pre_requisite_courses"] = []
        self.client.ajax_post(url, course_detail_json)
        resp = self.client.get_json(url)
        course_detail_json = json.loads(resp.content)
        self.assertEqual([], course_detail_json["pre_requisite_courses"])
Example #25
0
 def setUp(self):
     self.course_id = "Robot/999/Test_Course"
     CourseFactory.create(org="Robot", number="999", display_name="Test Course")
     self.user = UserFactory.create()
     self.attempt = SoftwareSecurePhotoVerification(status="submitted", user=self.user)
     self.attempt.save()
     self.receipt_id = self.attempt.receipt_id
     self.client = Client()
 def setUp(self):
     """
     Create courses in modulestore.
     """
     super(TestGenerateCourseOverview, self).setUp()
     self.course_key_1 = CourseFactory.create().id
     self.course_key_2 = CourseFactory.create().id
     self.command = generate_course_overview.Command()
 def setUpClass(cls):
     super(TestXblockUtils, cls).setUpClass()
     cls.course_mongo = CourseFactory.create(
         default_store=ModuleStoreEnum.Type.mongo, org="TestX", number="TS01", run="2015"
     )
     cls.course_split = CourseFactory.create(
         default_store=ModuleStoreEnum.Type.split, org="TestX", number="TS02", run="2015"
     )
Example #28
0
 def setUp(self):
     self.user = UserFactory.create()
     course = CourseFactory.create()
     self.course_key = course.id
     self.other_course_keys = []
     for __ in xrange(1, 5):
         self.other_course_keys.append(CourseFactory.create().id)
     self.cost = 40
Example #29
0
 def setUp(self):
     """
     Create courses in modulestore.
     """
     super(TestGenerateCourseBlocks, self).setUp()
     self.course_1 = CourseFactory.create()
     self.course_2 = CourseFactory.create()
     self.command = generate_course_blocks.Command()
Example #30
0
 def setUp(self):
     self.user = UserFactory.create(username="rusty", password="test")
     self.client.login(username="rusty", password="test")
     self.course_id = "Robot/999/Test_Course"
     CourseFactory.create(org="Robot", number="999", display_name="Test Course")
     verified_mode = CourseMode(
         course_id=self.course_id, mode_slug="verified", mode_display_name="Verified Certificate", min_price=50
     )
     verified_mode.save()