예제 #1
0
    def mock_courses_api(self):
        # Create existing seats to be removed by ingest
        audit_run_type = CourseRunType.objects.get(slug=CourseRunType.AUDIT)
        credit_run_type = CourseRunType.objects.get(slug=CourseRunType.CREDIT_VERIFIED_AUDIT)
        verified_run_type = CourseRunType.objects.get(slug=CourseRunType.VERIFIED_AUDIT)
        audit_run = CourseRunFactory(title_override='audit', key='audit/course/run', type=audit_run_type)
        verified_run = CourseRunFactory(title_override='verified', key='verified/course/run', type=verified_run_type)
        credit_run = CourseRunFactory(title_override='credit', key='credit/course/run', type=credit_run_type)
        no_currency_run = CourseRunFactory(title_override='no currency', key='nocurrency/course/run',
                                           type=verified_run_type)

        professional_type = SeatTypeFactory.professional()
        SeatFactory(course_run=audit_run, type=professional_type)
        SeatFactory(course_run=verified_run, type=professional_type)
        SeatFactory(course_run=credit_run, type=professional_type)
        SeatFactory(course_run=no_currency_run, type=professional_type)

        bodies = mock_data.ECOMMERCE_API_BODIES
        url = self.api_url + 'courses/'
        responses.add_callback(
            responses.GET,
            url,
            callback=mock_api_callback(url, bodies),
            content_type=JSON
        )
        return bodies
예제 #2
0
 def mock_ecommerce_courses_api(self):
     bodies = mock_data.ECOMMERCE_API_BODIES
     url = self.partner.ecommerce_api_url + 'courses/'
     responses.add_callback(responses.GET,
                            url,
                            callback=mock_api_callback(url, bodies),
                            content_type=JSON)
     return bodies
예제 #3
0
 def mock_programs_api(self):
     bodies = mock_data.PROGRAMS_API_BODIES
     url = self.partner.programs_api_url + 'programs/'
     responses.add_callback(responses.GET,
                            url,
                            callback=mock_api_callback(url, bodies),
                            content_type=JSON)
     return bodies
예제 #4
0
 def mock_api(self):
     bodies = mock_data.ORGANIZATIONS_API_BODIES
     url = self.api_url + 'organizations/'
     responses.add_callback(responses.GET,
                            url,
                            callback=mock_api_callback(url, bodies),
                            content_type=JSON)
     return bodies
 def mock_programs_api(self):
     bodies = mock_data.PROGRAMS_API_BODIES
     url = self.partner.programs_api_url + 'programs/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies),
         content_type=JSON
     )
     return bodies
예제 #6
0
 def mock_lms_courses_api(self):
     bodies = mock_data.COURSES_API_BODIES
     url = self.partner.courses_api_url + 'courses/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies, pagination=True),
         content_type=JSON
     )
     return bodies
 def mock_lms_courses_api(self):
     bodies = mock_data.COURSES_API_BODIES
     url = self.partner.courses_api_url + 'courses/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies, pagination=True),
         content_type=JSON
     )
     return bodies
 def mock_ecommerce_courses_api(self):
     bodies = mock_data.ECOMMERCE_API_BODIES
     url = self.partner.ecommerce_api_url + 'courses/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies),
         content_type=JSON
     )
     return bodies
 def mock_organizations_api(self):
     bodies = mock_data.ORGANIZATIONS_API_BODIES
     url = self.partner.organizations_api_url + 'organizations/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies),
         content_type=JSON
     )
     return bodies
예제 #10
0
 def mock_api(self, bodies=None):
     if not bodies:
         bodies = mock_data.COURSES_API_BODIES
     url = self.api_url + 'courses/'
     responses.add_callback(
         responses.GET,
         url,
         callback=mock_api_callback(url, bodies, pagination=True),
         content_type=JSON
     )
     return bodies
예제 #11
0
 def mock_api(self, bodies=None):
     if not bodies:
         bodies = mock_data.COURSES_API_BODIES
     url = self.api_url + 'courses/'
     responses.add_callback(responses.GET,
                            url,
                            callback=mock_api_callback(url,
                                                       bodies,
                                                       pagination=True),
                            content_type=JSON)
     return bodies
    def mock_api(self):
        bodies = mock_data.PROGRAMS_API_BODIES
        url = self.partner.programs_api_url + 'programs/'
        responses.add_callback(
            responses.GET,
            url,
            callback=mock_api_callback(url, bodies),
            content_type=JSON
        )

        # We exclude the one invalid item
        return bodies[:-1]
    def mock_access_token_api(self, requests_mock=None):
        body = {'access_token': ACCESS_TOKEN, 'expires_in': 30}
        requests_mock = requests_mock or responses

        url = self.partner.oidc_url_root.strip('/') + '/access_token'
        requests_mock.add_callback(responses.POST,
                                   url,
                                   callback=mock_api_callback(
                                       url, body, results_key=False),
                                   content_type=JSON)

        return body
예제 #14
0
    def mock_api(self):
        bodies = mock_data.PROGRAMS_API_BODIES
        self.create_mock_organizations(bodies)
        self.create_mock_courses_and_runs(bodies)

        url = self.api_url + 'programs/'
        responses.add_callback(responses.GET,
                               url,
                               callback=mock_api_callback(url, bodies),
                               content_type=JSON)

        # We exclude the one invalid item
        return bodies[:-1]
예제 #15
0
    def mock_api(self):
        bodies = mock_data.PROGRAMS_API_BODIES
        self.create_mock_organizations(bodies)
        self.create_mock_courses_and_runs(bodies)

        url = self.api_url + 'programs/'
        responses.add_callback(
            responses.GET,
            url,
            callback=mock_api_callback(url, bodies),
            content_type=JSON
        )

        # We exclude the one invalid item
        return bodies[:-1]
    def mock_access_token_api(self):
        body = {
            'access_token': ACCESS_TOKEN,
            'expires_in': 30
        }

        url = self.partner.oidc_url_root.strip('/') + '/access_token'
        responses.add_callback(
            responses.POST,
            url,
            callback=mock_api_callback(url, body, results_key=False),
            content_type=JSON
        )

        return body
예제 #17
0
    def mock_products_api(self,
                          alt_course=None,
                          alt_currency=None,
                          alt_mode=None,
                          has_stockrecord=True,
                          valid_stockrecord=True):
        """ Return a new Course Entitlement to be added by ingest """
        course = CourseFactory()

        bodies = [{
            "structure":
            "child",
            "product_class":
            "Course Entitlement",
            "title":
            "Course Intro to Everything",
            "price":
            "10.00",
            "expires":
            None,
            "attribute_values": [{
                "name": "certificate_type",
                "value": alt_mode if alt_mode else "verified",
            }, {
                "name":
                "UUID",
                "value":
                alt_course if alt_course else str(course.uuid),
            }],
            "is_available_to_buy":
            True,
            "stockrecords": []
        }]
        stockrecord = {
            "price_currency": alt_currency if alt_currency else "USD",
            "price_excl_tax": "10.00",
        }
        if valid_stockrecord:
            stockrecord.update({"partner_sku": "sku132"})
        if has_stockrecord:
            bodies[0]["stockrecords"].append(stockrecord)

        url = '{url}products/'.format(url=self.api_url)
        responses.add_callback(responses.GET,
                               url,
                               callback=mock_api_callback(url, bodies),
                               content_type=JSON)
        return bodies
예제 #18
0
    def mock_api(self):
        # Create existing seats to be removed by ingest
        audit_run = CourseRunFactory(title_override='audit', key='audit/course/run')
        verified_run = CourseRunFactory(title_override='verified', key='verified/course/run')
        credit_run = CourseRunFactory(title_override='credit', key='credit/course/run')
        no_currency_run = CourseRunFactory(title_override='no currency', key='nocurrency/course/run')

        SeatFactory(course_run=audit_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=verified_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=credit_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=no_currency_run, type=Seat.PROFESSIONAL)

        bodies = mock_data.ECOMMERCE_API_BODIES
        url = self.api_url + 'courses/'
        responses.add_callback(
            responses.GET,
            url,
            callback=mock_api_callback(url, bodies),
            content_type=JSON
        )
        return bodies
예제 #19
0
    def mock_courses_api(self):
        # Create existing seats to be removed by ingest
        audit_run = CourseRunFactory(title_override='audit', key='audit/course/run')
        verified_run = CourseRunFactory(title_override='verified', key='verified/course/run')
        credit_run = CourseRunFactory(title_override='credit', key='credit/course/run')
        no_currency_run = CourseRunFactory(title_override='no currency', key='nocurrency/course/run')

        SeatFactory(course_run=audit_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=verified_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=credit_run, type=Seat.PROFESSIONAL)
        SeatFactory(course_run=no_currency_run, type=Seat.PROFESSIONAL)

        bodies = mock_data.ECOMMERCE_API_BODIES
        url = self.api_url + 'courses/'
        responses.add_callback(
            responses.GET,
            url,
            callback=mock_api_callback(url, bodies),
            content_type=JSON
        )
        return bodies