def test_djpaddle_subscriber_model_invalid_name(settings): settings.DJPADDLE_SUBSCRIBER_MODEL = "fakemodel" from djpaddle import settings from importlib import reload reload(settings) from djpaddle.settings import get_subscriber_model with pytest.raises(ImproperlyConfigured): get_subscriber_model()
def test_djpaddle_subscriber_model_does_not_exist(settings): settings.DJPADDLE_SUBSCRIBER_MODEL = "app_label.model_name" from djpaddle import settings from importlib import reload reload(settings) from djpaddle.settings import get_subscriber_model with pytest.raises(ImproperlyConfigured): get_subscriber_model()
def test_missing_djpaddle_subscriber_model(settings): settings.DJPADDLE_SUBSCRIBER_MODEL = "djpaddle.Price" from djpaddle import settings from importlib import reload reload(settings) from djpaddle.settings import get_subscriber_model with pytest.raises(ImproperlyConfigured): get_subscriber_model()
def test_djpaddle_subscriber_model_does_not_exist(settings): settings.DJPADDLE_SUBSCRIBER_MODEL = "app_label.model_name" from djpaddle import settings from importlib import reload reload(settings) from djpaddle.settings import get_subscriber_model with pytest.raises(ImproperlyConfigured) as error: get_subscriber_model() message = ("DJPADDLE_SUBSCRIBER_MODEL refers to model '{}' " "that has not been installed.") assert error.match(message.format(settings.DJPADDLE_SUBSCRIBER_MODEL))
def test_djpaddle_subscriber_model_invalid_name(settings): settings.DJPADDLE_SUBSCRIBER_MODEL = "fakemodel" from djpaddle import settings from importlib import reload reload(settings) from djpaddle.settings import get_subscriber_model with pytest.raises(ImproperlyConfigured) as error: get_subscriber_model() message = ( "DJPADDLE_SUBSCRIBER_MODEL must be of the form 'app_label.model_name'." ) assert error.match(message)
def test_get_subscriptions_by_subscriber(self): Subscriber = settings.get_subscriber_model() subscriber = Subscriber.objects.create(username="******", email="*****@*****.**") plan = Plan.objects.create( pk=1, name="name", billing_type="month", billing_period=1, trial_days=0, ) Subscription.objects.create( cancel_url= "https://checkout.paddle.com/subscription/cancel?user=1&subscription=2&hash=aaaaaa", # NOQA: E501 checkout_id="1", created_at=timezone.now(), currency="EUR", email="*****@*****.**", event_time=timezone.now(), id=1, marketing_consent=True, next_bill_date=timezone.now(), passthrough="", plan=plan, quantity=1, source="", status="active", subscriber=None, unit_price=0.0, update_url= "https://checkout.paddle.com/subscription/update?user=5&subscription=4&hash=aaaaaa", # NOQA: E501 updated_at=timezone.now(), ) subscriptions = mappers.get_subscriptions_by_subscriber( subscriber, Subscription.objects) self.assertEqual(1, len(subscriptions.all()))
def test_get_subscriber_by_payload(self): Subscriber = settings.get_subscriber_model() payload = {"email": "*****@*****.**"} with self.assertRaises(Subscriber.DoesNotExist): mappers.get_subscriber_by_payload(Subscriber, payload)