Esempio n. 1
0
  def test_hacker_membership(self):
    now = datetime.datetime.now()
    def validate(email):
      user = get_user_model().objects.get(email=email)
      self.assertEqual(user.level,product.level)
      subscription = user.subscription_set.get()
      self.assertEqual(subscription.paid_until.date(),add_months(now.date(),subscription.months))
      self.assertTrue(subscription.owed <= 0)

    level = Level.objects.get(name="Hacker")
    for product in level.product_set.all():
      new_email = "*****@*****.**"%product.pk
      get_user_model().objects.filter(email=new_email).delete()
      data = get_membership_query(product=product,payer_email=new_email)
      paypal_post(self,data)
      validate(new_email)

      # reposting the same data should not change anything
      paypal_post(self,data)
      validate(new_email)
      subjects = [u'New account information', u'TXRX Member Application Status for %s'%new_email.split("@")[0]]
      self.assertTrue(check_subjects(subjects))
      self.assertTrue(check_recipients([[new_email],[new_email]]))
      mail.outbox = []

    get_user_model().objects.get(email=new_email).delete()
    PayPalIPN.objects.filter(txn_id=data['txn_id']).delete()
Esempio n. 2
0
    def test_course(self):
        #make sure students and instructors get an email
        i_email = '*****@*****.**'
        s_email = '*****@*****.**'
        s2_email = '*****@*****.**'
        User = get_user_model()
        User.objects.filter(email__in=[i_email, s_email, s2_email]).delete()
        instructor, new = get_or_create_student(i_email, send_mail=False)
        instructor.is_staff = True
        instructor.save()

        self.session1.user = instructor
        self.session2.user = instructor
        self.session1.save()
        self.session2.save()

        # enroll student in 1 class
        student, new = get_or_create_student(s_email, send_mail=False)
        Enrollment.objects.create(user=student, session=self.session1)

        # enroll student2 in 2 classes
        student2, new = get_or_create_student(s2_email, send_mail=False)
        Enrollment.objects.create(user=student2, session=self.session1)
        Enrollment.objects.create(user=student2, session=self.session2)

        # send out reminders and check that they went out
        call_command("course_reminder")
        subjects = [
            u'Class tomorrow!', u'Class tomorrow!',
            u"You're teaching tomorrow at 1 p.m.",
            u"You're teaching tomorrow at 6 p.m."
        ]
        recipients = [[i_email], [i_email], [s2_email], [s_email]]
        self.assertTrue(check_subjects(subjects))
        self.assertTrue(check_recipients(recipients))

        # send out reminders again. Make sure none went out
        mail.outbox = []
        call_command("course_reminder")
        self.assertTrue(check_subjects([]))
        self.assertTrue(check_recipients([]))
Esempio n. 3
0
  def test_course(self):
    #make sure students and instructors get an email
    i_email = '*****@*****.**'
    s_email = '*****@*****.**'
    s2_email = '*****@*****.**'
    User = get_user_model()
    User.objects.filter(email__in=[i_email,s_email,s2_email]).delete()
    instructor, new = get_or_create_student(i_email,send_mail=False)
    instructor.is_staff = True
    instructor.save()

    self.session1.user = instructor
    self.session2.user = instructor
    self.session1.save()
    self.session2.save()

    # enroll student in 1 class
    student, new = get_or_create_student(s_email,send_mail=False)
    Enrollment.objects.create(user=student,session=self.session1)

    # enroll student2 in 2 classes
    student2,new = get_or_create_student(s2_email,send_mail=False)
    Enrollment.objects.create(user=student2,session=self.session1)
    Enrollment.objects.create(user=student2,session=self.session2)

    # send out reminders and check that they went out
    call_command("course_reminder")
    subjects = [
      u'Class tomorrow!', u'Class tomorrow!',
      u"You're teaching tomorrow at 1 p.m.", u"You're teaching tomorrow at 6 p.m."
    ]
    recipients = [[i_email], [i_email], [s2_email], [s_email]]
    self.assertTrue(check_subjects(subjects))
    self.assertTrue(check_recipients(recipients))

    # send out reminders again. Make sure none went out
    mail.outbox = []
    call_command("course_reminder")
    self.assertTrue(check_subjects([]))
    self.assertTrue(check_recipients([]))