Beispiel #1
0
def test_schemas():
    eventing_request = ExportRequest(course_id=fake_course_id,
                                     export_type=EXPORT_TYPE_CLICKSTREAM)
    gradebook_request = ExportRequest(course_id=fake_course_id,
                                      export_type=EXPORT_TYPE_GRADEBOOK)
    all_tables_request = ExportRequest(course_id=fake_course_id,
                                       export_type=EXPORT_TYPE_TABLES,
                                       schema_names=SCHEMA_NAMES)

    assert eventing_request.schema_names_display is None
    assert gradebook_request.schema_names_display is None
    assert all_tables_request.schema_names_display == 'all'
Beispiel #2
0
    def request_clickstream(self, export_type = "RESEARCH_EVENTING", anonymity_level = "HASHED_IDS_NO_PII",
                            statement_of_purpose = "Weekly backup of course data"):

        if self.verbose:
            print "Requesting clickstream data ({}) for period {} to {}".format(self.course_slug, self.interval[0], self.interval[1])

        if self.log:
            logging.info("Requesting clickstream data ({}) for period {} to {}".format(self.course_slug, self.interval[0], self.interval[1]))

        # Construct request
        er = ExportRequest(course_id=self.course_id, export_type=export_type, anonymity_level = anonymity_level,
                           statement_of_purpose = statement_of_purpose, interval=self.interval)
        # Fire request
        try:
            ERM = api.post(er)[0]
        except:
            errors = ' '.join([str(e) for e in sys.exc_info()])
            if self.log:
                logging.error("Request failed ({}) with errors {}".format(self.course_slug, errors))
            print errors
            raise FailedRequest("Failed request")

        if self.log:
            logging.info("Request successfull ({})".format(self.course_slug))

        # Add id to self
        vals = ERM.to_json()
        self.id_ = vals['id']
        self.type_ = "CLICKSTREAM"
        self.metadata = vals["metadata"]
        self.schemaNames = "NONE"
Beispiel #3
0
def test_export_request_deserialize_from_json():
    export_request_json = {
        'scope': {
            'typeName': 'courseContext',
            'definition': {
                'courseId': fake_course_id
            }
        }
    }
    export_request = ExportRequest.from_json(export_request_json)

    assert ExportRequest(course_id=fake_course_id) == export_request
Beispiel #4
0
def test_export_request_serialize_to_json():
    export_request = ExportRequest(course_id=fake_course_id)
    expected_result = {
        'scope': {
            'typeName': 'courseContext',
            'definition': {
                'courseId': fake_course_id
            }
        }
    }

    assert export_request.to_json() == expected_result
Beispiel #5
0
    def request_schemas(self,
                        export_type="RESEARCH_WITH_SCHEMAS",
                        anonymity_level="HASHED_IDS_NO_PII",
                        statement_of_purpose="Weekly backup of course data",
                        schema_names=[
                            "demographics", "users", "course_membership",
                            "course_progress", "feedback", "assessments",
                            "course_grades", "peer_assignments", "discussions",
                            "programming_assignments", "course_content"
                        ]):

        if self.log:
            logging.info("Requesting table data ({})".format(self.course_slug))

        # Construct request
        er = ExportRequest(course_id=self.course_id,
                           export_type=export_type,
                           anonymity_level=anonymity_level,
                           statement_of_purpose=statement_of_purpose,
                           schema_names=schema_names)
        # Fire request
        try:
            ERM = api.post(er)[0]
        except:  # Find out specific error
            errors = ' '.join([str(e) for e in sys.exc_info()])
            if self.log:
                logging.error("Request failed ({}) with errors {}".format(
                    self.course_slug, errors))
            print errors
            raise FailedRequest("Failed request")

        if self.log:
            logging.info("Request successfull ({})".format(self.course_slug))

        # Add info to self
        vals = ERM.to_json()
        self.id_ = vals['id']
        self.type_ = "TABLES"
        self.metadata = vals["metadata"]
        self.schemaNames = vals["schemaNames"]
Beispiel #6
0
def test_scope_id():
    export_request = ExportRequest(course_id=fake_course_id)

    assert export_request.scope_id == fake_course_id
Beispiel #7
0
def test_partner_id_inference(lookup_partner_id_by_short_name):
    lookup_partner_id_by_short_name.return_value = fake_partner_id
    export_request = ExportRequest.from_args(
        partner_short_name=fake_partner_short_name)

    assert ExportRequest(partner_id=fake_partner_id) == export_request
Beispiel #8
0
def test_course_id_inference(lookup_course_id_by_slug):
    lookup_course_id_by_slug.return_value = fake_course_id
    export_request = ExportRequest.from_args(course_slug=fake_course_slug)

    assert ExportRequest(course_id=fake_course_id) == export_request
Beispiel #9
0
def test_create_from_args():
    export_request = ExportRequest.from_args(course_id=fake_course_id)
    assert ExportRequest(course_id=fake_course_id) == export_request