Esempio n. 1
0
    def test_purchased_items_btw_dates(self):
        report = initialize_report("itemized_purchase_report", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
        purchases = report.rows()

        # since there's not many purchases, just run through the generator to make sure we've got the right number
        self.assertEqual(len(list(purchases)), 2)

        report = initialize_report("itemized_purchase_report", self.now + self.FIVE_MINS, self.now + self.FIVE_MINS + self.FIVE_MINS)
        no_purchases = report.rows()
        self.assertEqual(len(list(no_purchases)), 0)
Esempio n. 2
0
    def test_purchased_items_btw_dates(self):
        report = initialize_report("itemized_purchase_report", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
        purchases = report.rows()

        # since there's not many purchases, just run through the generator to make sure we've got the right number
        num_purchases = 0
        for item in purchases:
            num_purchases += 1
        self.assertEqual(num_purchases, 2)

        report = initialize_report("itemized_purchase_report", self.now + self.FIVE_MINS, self.now + self.FIVE_MINS + self.FIVE_MINS)
        no_purchases = report.rows()

        num_purchases = 0
        for item in no_purchases:
            num_purchases += 1
        self.assertEqual(num_purchases, 0)
Esempio n. 3
0
 def test_basic_uni_revenue_share_csv(self):
     report = initialize_report(
         "university_revenue_share", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS, "A", "Z"
     )
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     self.assertEqual(csv.replace("\r\n", "\n").strip(), self.CORRECT_UNI_REVENUE_SHARE_CSV.strip())
Esempio n. 4
0
    def test_refund_report_rows(self):
        report = initialize_report("refund_report", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
        refunded_certs = report.rows()

        # check that we have the right number
        self.assertEqual(len(list(refunded_certs)), 2)

        self.assertTrue(CertificateItem.objects.get(user=self.first_refund_user, course_id=self.course_key))
        self.assertTrue(CertificateItem.objects.get(user=self.second_refund_user, course_id=self.course_key))
Esempio n. 5
0
 def test_purchased_csv(self):
     """
     Tests that a generated purchase report CSV is as we expect
     """
     report = initialize_report("itemized_purchase_report", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     csv_file.close()
     # Using excel mode csv, which automatically ends lines with \r\n, so need to convert to \n
     self.assertEqual(csv.replace('\r\n', '\n').strip(), self.CORRECT_CSV.strip())
Esempio n. 6
0
 def test_purchased_csv(self):
     """
     Tests that a generated purchase report CSV is as we expect
     """
     report = initialize_report("itemized_purchase_report",
                                self.now - self.FIVE_MINS,
                                self.now + self.FIVE_MINS)
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     csv_file.close()
     # Using excel mode csv, which automatically ends lines with \r\n, so need to convert to \n
     self.assertEqual(
         csv.replace('\r\n', '\n').strip(), self.CORRECT_CSV.strip())
Esempio n. 7
0
    def test_refund_report_rows(self):
        report = initialize_report("refund_report", self.now - self.FIVE_MINS,
                                   self.now + self.FIVE_MINS)
        refunded_certs = report.rows()

        # check that we have the right number
        self.assertEqual(len(list(refunded_certs)), 2)

        self.assertTrue(
            CertificateItem.objects.get(user=self.first_refund_user,
                                        course_id=self.course_key))
        self.assertTrue(
            CertificateItem.objects.get(user=self.second_refund_user,
                                        course_id=self.course_key))
Esempio n. 8
0
 def test_report_csv_itemized(self):
     report_type = 'itemized_purchase_report'
     start_date = '1970-01-01'
     end_date = '2100-01-01'
     PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': start_date,
                                                                 'end_date': end_date,
                                                                 'requested_report': report_type})
     self.assertEqual(response['Content-Type'], 'text/csv')
     report = initialize_report(report_type, start_date, end_date)
     self.assertIn(",".join(report.header()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE_ITEMIZED_PURCHASE, response.content)
Esempio n. 9
0
 def test_report_csv_itemized(self):
     report_type = 'itemized_purchase_report'
     start_date = '1970-01-01'
     end_date = '2100-01-01'
     PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': start_date,
                                                                 'end_date': end_date,
                                                                 'requested_report': report_type})
     self.assertEqual(response['Content-Type'], 'text/csv')
     report = initialize_report(report_type, start_date, end_date)
     self.assertIn(",".join(report.header()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE_ITEMIZED_PURCHASE, response.content)
Esempio n. 10
0
 def test_report_csv_itemized(self):
     report_type = "itemized_purchase_report"
     start_date = "1970-01-01"
     end_date = "2100-01-01"
     PaidCourseRegistration.add_to_order(self.cart, self.course_id)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(
         reverse("payment_csv_report"),
         {"start_date": start_date, "end_date": end_date, "requested_report": report_type},
     )
     self.assertEqual(response["Content-Type"], "text/csv")
     report = initialize_report(report_type, start_date, end_date)
     self.assertIn(",".join(report.header()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE_ITEMIZED_PURCHASE, response.content)
Esempio n. 11
0
 def test_report_csv_university_revenue_share(self):
     report_type = 'university_revenue_share'
     start_date = '1970-01-01'
     end_date = '2100-01-01'
     start_letter = 'A'
     end_letter = 'Z'
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': start_date,
                                                                 'end_date': end_date,
                                                                 'start_letter': start_letter,
                                                                 'end_letter': end_letter,
                                                                 'requested_report': report_type})
     self.assertEqual(response['Content-Type'], 'text/csv')
     report = initialize_report(report_type, start_date, end_date, start_letter, end_letter)
     self.assertIn(",".join(report.header()), response.content)
Esempio n. 12
0
 def test_report_csv_university_revenue_share(self):
     report_type = 'university_revenue_share'
     start_date = '1970-01-01'
     end_date = '2100-01-01'
     start_letter = 'A'
     end_letter = 'Z'
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': start_date,
                                                                 'end_date': end_date,
                                                                 'start_letter': start_letter,
                                                                 'end_letter': end_letter,
                                                                 'requested_report': report_type})
     self.assertEqual(response['Content-Type'], 'text/csv')
     report = initialize_report(report_type, start_date, end_date, start_letter, end_letter)
     self.assertIn(",".join(report.header()), response.content)
 def test_purchased_csv(self):
     """
     Tests that a generated purchase report CSV is as we expect
     """
     report = initialize_report("itemized_purchase_report",
                                self.now - self.FIVE_MINS,
                                self.now + self.FIVE_MINS)
     # Note :In this we are using six.StringIO as memory buffer to read/write csv for testing.
     # In case of py2 that will be BytesIO so we will need to decode the value before comparison.
     csv_file = StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue() if six.PY3 else csv_file.getvalue().decode(
         'utf-8')
     csv_file.close()
     # Using excel mode csv, which automatically ends lines with \r\n, so need to convert to \n
     self.assertEqual(
         csv.replace('\r\n', '\n').strip(), self.CORRECT_CSV.strip())
Esempio n. 14
0
 def test_report_csv_university_revenue_share(self):
     report_type = "university_revenue_share"
     start_date = "1970-01-01"
     end_date = "2100-01-01"
     start_letter = "A"
     end_letter = "Z"
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(
         reverse("payment_csv_report"),
         {
             "start_date": start_date,
             "end_date": end_date,
             "start_letter": start_letter,
             "end_letter": end_letter,
             "requested_report": report_type,
         },
     )
     self.assertEqual(response["Content-Type"], "text/csv")
     report = initialize_report(report_type, start_date, end_date, start_letter, end_letter)
     self.assertIn(",".join(report.header()), response.content)
Esempio n. 15
0
 def test_basic_cert_status_csv(self):
     report = initialize_report("certificate_status", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS, 'A', 'Z')
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     self.assertEqual(csv.replace('\r\n', '\n').strip(), self.CORRECT_CERT_STATUS_CSV.strip())
Esempio n. 16
0
 def test_basic_uni_revenue_share_csv(self):
     report = initialize_report("university_revenue_share", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS, 'A', 'Z')
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     self.assertEqual(csv.replace('\r\n', '\n').strip(), self.CORRECT_UNI_REVENUE_SHARE_CSV.strip())
Esempio n. 17
0
 def test_basic_cert_status_csv(self):
     report = initialize_report("certificate_status", self.now - self.FIVE_MINS, self.now + self.FIVE_MINS, 'A', 'Z')
     csv_file = StringIO.StringIO()
     report.write_csv(csv_file)
     csv = csv_file.getvalue()
     self.assertEqual(csv.replace('\r\n', '\n').strip(), self.CORRECT_CERT_STATUS_CSV.strip())