def test_get_context_data(self): view = DowngradeConfirmationView() view.request = self.factory.get('/', data={'tier': 'tier1'}) data = view.get_context_data() self.assertIsInstance(data.get('form'), TierChangeForm) self.assertEqual(data.get('tier'), self.tier1) self.assertEqual(data.get('tier_info'), self.tier_info) self.assertIsInstance(data.get('admins_to_demote'), list) self.assertIsInstance(data.get('videos_to_deactivate'), list) self.assertIsInstance(data.get('have_theme'), bool)
def test_get_context_data__enforced__cancellation__no_subscription(self): """ If payments are enforced, but there is no active subscription, a non-paypal-based form should be used. """ self.tier_info.enforce_payments = True self.tier_info.save() view = DowngradeConfirmationView() view.request = self.factory.get('/', data={'tier': 'tier1'}) data = view.get_context_data() self.assertIsInstance(data.get('form'), TierChangeForm) self.assertEqual(data.get('tier'), self.tier1) self.assertEqual(data.get('tier_info'), self.tier_info) self.assertIsInstance(data.get('admins_to_demote'), list) self.assertIsInstance(data.get('videos_to_deactivate'), list) self.assertIsInstance(data.get('have_theme'), bool)
def test_get_context_data__enforced__cancellation(self): """ If payments are enforced, a paypal-based form should be used. """ self.tier_info.enforce_payments = True self.tier_info.save() view = DowngradeConfirmationView() view.request = self.factory.get('/', data={'tier': 'tier1'}) with mock.patch.object(self.tier_info, 'subscription', signup_or_modify=self.create_ipn()): data = view.get_context_data() self.assertIsInstance(data.get('form'), PayPalCancellationForm) self.assertEqual(data.get('tier'), self.tier1) self.assertEqual(data.get('tier_info'), self.tier_info) self.assertIsInstance(data.get('admins_to_demote'), list) self.assertIsInstance(data.get('videos_to_deactivate'), list) self.assertIsInstance(data.get('have_theme'), bool)
def test_get_context_data__enforced(self): """ If payments are enforced, a paypal-based form should be used. """ self.tier_info.enforce_payments = True self.tier_info.save() self.tier1.price = 10 self.tier1.save() view = DowngradeConfirmationView() view.request = self.factory.get('/', data={'tier': 'tier1'}) data = view.get_context_data() self.assertIsInstance(data.get('form'), PayPalSubscriptionForm) self.assertEqual(data.get('tier'), self.tier1) self.assertEqual(data.get('tier_info'), self.tier_info) self.assertIsInstance(data.get('admins_to_demote'), list) self.assertIsInstance(data.get('videos_to_deactivate'), list) self.assertIsInstance(data.get('have_theme'), bool)