Exemplo n.º 1
0
 def test_course_tier_mandatory(self):
     """
     Test that an attempt to serialize financial aid information will raise an exception if no tiers are created.
     """
     new_program = ProgramFactory.create(live=True, financial_aid_availability=True, price=1000)
     with self.assertRaises(ImproperlyConfigured):
         FinancialAidDashboardSerializer.serialize(self.user, new_program)
Exemplo n.º 2
0
 def test_course_tier_mandatory(self):
     """
     Test that an attempt to serialize financial aid information will raise an exception if no tiers are created.
     """
     new_program = ProgramFactory.create(live=True,
                                         financial_aid_availability=True,
                                         price=1000)
     with self.assertRaises(ImproperlyConfigured):
         FinancialAidDashboardSerializer.serialize(self.user, new_program)
Exemplo n.º 3
0
def get_info_for_program(mmtrack):
    """
    Helper function that formats a program with all the courses and runs

    Args:
        mmtrack (dashboard.utils.MMTrack): a instance of all user information about a program

    Returns:
        dict: a dictionary containing information about the program
    """
    # basic data for the program
    data = {
        "id": mmtrack.program.pk,
        "description": mmtrack.program.description,
        "title": mmtrack.program.title,
        "financial_aid_availability": mmtrack.financial_aid_available,
        "courses": [],
        "pearson_exam_status": mmtrack.get_pearson_exam_status(),
        "grade_average": mmtrack.calculate_final_grade_average(),
        "certificate": mmtrack.get_program_certificate_url(),
    }
    if mmtrack.financial_aid_available:
        data["financial_aid_user_info"] = FinancialAidDashboardSerializer.serialize(mmtrack.user, mmtrack.program)
        data["grade_records_url"] = reverse('grade_records', args=[mmtrack.get_program_enrollment().hash])
    else:
        program_letter_url = mmtrack.get_program_letter_url()
        if program_letter_url:
            data["program_letter_url"] = program_letter_url
    for course in mmtrack.program.course_set.all():
        data['courses'].append(
            get_info_for_course(course, mmtrack)
        )
    return data
Exemplo n.º 4
0
def get_info_for_program(mmtrack):
    """
    Helper function that formats a program with all the courses and runs

    Args:
        mmtrack (dashboard.utils.MMTrack): a instance of all user information about a program

    Returns:
        dict: a dictionary containing information about the program
    """
    # basic data for the program
    data = {
        "id": mmtrack.program.pk,
        "description": mmtrack.program.description,
        "title": mmtrack.program.title,
        "financial_aid_availability": mmtrack.financial_aid_available,
        "courses": [],
        "pearson_exam_status": mmtrack.get_pearson_exam_status(),
        "grade_average": mmtrack.calculate_final_grade_average(),
        "certificate": mmtrack.get_program_certificate_url(),
    }
    if mmtrack.financial_aid_available:
        data[
            "financial_aid_user_info"] = FinancialAidDashboardSerializer.serialize(
                mmtrack.user, mmtrack.program)
        data["grade_records_url"] = reverse(
            'grade_records', args=[mmtrack.get_program_enrollment().hash])
    else:
        program_letter_url = mmtrack.get_program_letter_url()
        if program_letter_url:
            data["program_letter_url"] = program_letter_url
    for course in mmtrack.program.course_set.all():
        data['courses'].append(get_info_for_course(course, mmtrack))
    return data
Exemplo n.º 5
0
 def test_with_non_financial_aid_program(self):
     """
     Test that a non-financial aid program will serialize to an empty dict
     """
     non_fa_program = ProgramFactory.create(
         live=True, financial_aid_availability=False)
     assert FinancialAidDashboardSerializer.serialize(
         self.user, non_fa_program) == {}
Exemplo n.º 6
0
 def test_financial_aid_with_application(self):
     """
     Test that a user that has a FinancialAid record with a non-reset status will have serialized financial aid
     information that indicates that they have applied
     """
     fin_aid = FinancialAidFactory.create(
         user=self.user,
         tier_program=self.min_tier_program,
         date_documents_sent=None,
     )
     serialized = FinancialAidDashboardSerializer.serialize(self.user, self.program)
     assert serialized == {
         "id": fin_aid.id,
         "has_user_applied": True,
         "application_status": fin_aid.status,
         "min_possible_cost": 250,
         "max_possible_cost": 1000,
         "date_documents_sent": None,
     }
Exemplo n.º 7
0
 def test_financial_aid_with_application_in_reset(self):
     """
     Test that a user that has a FinancialAid record with the reset status will have serialized financial aid
     information that indicates that they have not applied
     """
     FinancialAidFactory.create(user=self.user,
                                tier_program=self.min_tier_program,
                                date_documents_sent=None,
                                status=FinancialAidStatus.RESET)
     serialized = FinancialAidDashboardSerializer.serialize(
         self.user, self.program)
     assert serialized == {
         "id": None,
         "has_user_applied": False,
         "application_status": None,
         "min_possible_cost": 250,
         "max_possible_cost": 1000,
         "date_documents_sent": None,
     }
Exemplo n.º 8
0
 def test_financial_aid_with_documents_sent(self):
     """
     Test that a user that has a FinancialAid record and has sent documents will have serialized financial aid
     information that indicates the date that documents were sent
     """
     now = now_in_utc()
     fin_aid = FinancialAidFactory.create(
         user=self.user,
         tier_program=self.min_tier_program,
         date_documents_sent=now,
     )
     serialized = FinancialAidDashboardSerializer.serialize(self.user, self.program)
     assert serialized == {
         "id": fin_aid.id,
         "has_user_applied": True,
         "application_status": fin_aid.status,
         "min_possible_cost": 250,
         "max_possible_cost": 1000,
         "date_documents_sent": now.date(),
     }
Exemplo n.º 9
0
 def test_financial_aid_with_documents_sent(self):
     """
     Test that a user that has a FinancialAid record and has sent documents will have serialized financial aid
     information that indicates the date that documents were sent
     """
     now = now_in_utc()
     fin_aid = FinancialAidFactory.create(
         user=self.user,
         tier_program=self.min_tier_program,
         date_documents_sent=now,
     )
     serialized = FinancialAidDashboardSerializer.serialize(
         self.user, self.program)
     assert serialized == {
         "id": fin_aid.id,
         "has_user_applied": True,
         "application_status": fin_aid.status,
         "min_possible_cost": 250,
         "max_possible_cost": 1000,
         "date_documents_sent": now.date(),
     }
Exemplo n.º 10
0
 def test_with_non_financial_aid_program(self):
     """
     Test that a non-financial aid program will serialize to an empty dict
     """
     non_fa_program = ProgramFactory.create(live=True, financial_aid_availability=False)
     assert FinancialAidDashboardSerializer.serialize(self.user, non_fa_program) == {}