Example #1
0
    def test_url_tracking(self):
        push_message = PushMessage(title="Title",
                                   body="Body",
                                   url_args="1",
                                   account_key="ABC")
        push_message.save()
        register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        profile.account_key = "ABC"
        profile.save()

        resp = c.get(reverse('track_open', args=[push_message.id]))

        self.assertEquals(PushMessage.objects.all().count(), 1)
        self.assertEquals(ClientProfile.objects.all().count(), 1)
        self.assertRedirects(resp,
                             'http://testwebsite.com?p=1&source=push_monkey')

        profile.url_format_string = 'http://newwebsite.com?p='
        profile.save()

        resp = c.get(reverse('track_open', args=[push_message.id]))

        self.assertRedirects(resp,
                             'http://newwebsite.com?p=1&source=push_monkey')
Example #2
0
    def test_ipn_received_without_push_package(self):
        # sign up a user
        resp = register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        # prepare a push package
        package = create_push_package(os.path.join(settings.MEDIA_ROOT,
                                                   'test'))
        # upload icon
        profile_image = ProfileImage(profile=profile)
        image_path = os.path.join(settings.MEDIA_ROOT, 'test', 'image.png')
        profile_image.image = SimpleUploadedFile(name='test_image.png',
                                                 content=open(
                                                     image_path, 'rb').read(),
                                                 content_type='image/png')
        profile_image.save()
        # mock PayPal IPN response
        mock_sender = MockIPNResponse(user_id=profile.user.id,
                                      plan_type=plans.PRO,
                                      time_units="M")

        # state before the PayPal IPN Response
        self.assertEqual(pushmonkey.models.PushPackage.objects.count(), 1)
        self.assertEqual(Plan.objects.count(), 0)
        self.assertFalse(profile.has_push_package())

        # make the PayPal IPN call
        mark_payment(mock_sender)

        # state after the PayPal IPN Response
        self.assertEqual(Plan.objects.count(), 1)
        self.assertEqual(pushmonkey.models.PushPackage.objects.count(), 1)
        # retrieve the profile from the database again to have the new properties values
        profile = ClientProfile.objects.all()[0]
        self.assertTrue(profile.has_push_package())
Example #3
0
    def test_payment_processing_from_wp(self):
        resp_register = register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        logged_in = c.login(username='******', password='******')
        resp = c.get(reverse('payment_processing', args=[plans.STARTER]))

        self.assertTrue(logged_in)
        self.assertRedirects(
            resp, profile.return_url +
            "&push_monkey_package_pending=1&push_monkey_registered=1")
Example #4
0
    def test_pre_expiration_email(self):
        resp_register = register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        plan1 = Plan(user=profile.user,
                     type=plans.TRIAL,
                     end_at=datetime.now() + timedelta(days=11),
                     status='active')
        plan1.save()
        c = Command()
        c.handle()
        subjects = [m.subject for m in mail.outbox]

        self.assertTrue("It's almost that time" in subjects)
Example #5
0
    def test_url_tracking_custom_url(self):
        push_message = PushMessage(title="Title",
                                   body="Body",
                                   url_args="http://google.com",
                                   account_key="ABC",
                                   custom=True)
        push_message.save()
        res = register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        profile.account_key = "ABC"
        profile.save()

        resp = c.get(reverse('track_open', args=[push_message.id]))

        self.assertRedirects(resp, 'http://google.com')
Example #6
0
    def test_create_fixed_plan(self):
        resp_register = register_user_from_wp()
        profile = ClientProfile.objects.all()[0]
        plan = Plan.objects.create_fixed_plan(profile.user)

        self.assertEqual(Plan.objects.all().count(), 1)