示例#1
0
 def setUp(self):
     self.p = PaymillContext(test_config.api_key)
     self.payment = self.p.get_payment_service().create(test_config.magic_token)
     self.subscription = self.p.get_subscription_service().create_with_amount(self.payment.id,
                                                                              TestSubscriptionService.amount,
                                                                              TestSubscriptionService.currency,
                                                                              TestSubscriptionService.interval)
 def setUp(self):
     TestTransactionService.amount = test_config.get_next_amount()
     self.p = PaymillContext(api_key=test_config.api_key)
     self.transaction = self.p.get_transaction_service().create_with_token(token=test_config.magic_token,
                                                                           amount=TestTransactionService.amount,
                                                                           currency=TestTransactionService.currency,
                                                                           description=TestTransactionService.description)
示例#3
0
 def test_subscription_cancel(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(
         payment.id, TestSubscriptionService.amount,
         TestSubscriptionService.currency, TestSubscriptionService.interval)
     s = p.get_subscription_service().cancel(subscription)
     self.assertIsInstance(s, Subscription)
 def setUp(self):
     self.p = PaymillContext(api_key=test_config.api_key)
     self.preauthorization = self.p.get_preauthorization_service(
     ).create_with_token(
         token=test_config.magic_token,
         amount=TestPreauthorizationService.amount,
         currency=TestPreauthorizationService.currency,
         description=TestPreauthorizationService.description)
 def test_subscription_cancel(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                    TestSubscriptionService.amount,
                                                                    TestSubscriptionService.currency,
                                                                    TestSubscriptionService.interval)
     s = p.get_subscription_service().cancel(subscription)
     self.assertIsInstance(s, Subscription)
示例#6
0
 def test_subscription_update_default_sets_interval(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(
         payment.id, TestSubscriptionService.amount,
         TestSubscriptionService.currency, TestSubscriptionService.interval)
     subscription.interval = '1 MONTH,FRIDAY'
     s = p.get_subscription_service().update(subscription)
     self.assertEqual('1 MONTH,FRIDAY', s.interval)
 def test_subscription_update_default_sets_interval(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                    TestSubscriptionService.amount,
                                                                    TestSubscriptionService.currency,
                                                                    TestSubscriptionService.interval)
     subscription.interval = '1 MONTH,FRIDAY'
     s = p.get_subscription_service().update(subscription)
     self.assertEqual('1 MONTH,FRIDAY', s.interval)
示例#8
0
 def test_subscription_update_with_amount_sets_amount(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(
         payment.id, TestSubscriptionService.amount,
         TestSubscriptionService.currency, TestSubscriptionService.interval)
     subscription.amount = 5600
     s = p.get_subscription_service().update_with_amount(
         subscription, amount_change_type=1)
     self.assertEqual(5600, s.amount)
 def test_subscription_update_with_amount_sets_amount(self):
     p = PaymillContext(test_config.api_key)
     payment = p.get_payment_service().create(test_config.magic_token)
     subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                    TestSubscriptionService.amount,
                                                                    TestSubscriptionService.currency,
                                                                    TestSubscriptionService.interval)
     subscription.amount = 5600
     s = p.get_subscription_service().update_with_amount(subscription, amount_change_type=1)
     self.assertEqual(5600, s.amount)
示例#10
0
class TestTransactionService(unittest.TestCase):

    amount = None
    currency = 'EUR'
    description = 'Test Python Transactions'

    def setUp(self):
        TestTransactionService.amount = test_config.get_next_amount()
        self.p = PaymillContext(api_key=test_config.api_key)
        self.transaction = self.p.get_transaction_service().create_with_token(token=test_config.magic_token,
                                                                              amount=TestTransactionService.amount,
                                                                              currency=TestTransactionService.currency,
                                                                              description=TestTransactionService.description)

    def tearDown(self):
        del self.p
        del self.transaction

    def test_create_sets_amount(self):
        self.assertEqual(TestTransactionService.amount, self.transaction.amount)

    def test_create_sets_currency(self):
        self.assertEqual(TestTransactionService.currency, self.transaction.currency)

    def test_create_sets_description(self):
        self.assertEqual(TestTransactionService.description, self.transaction.description)
 def setUp(self):
     self.p = PaymillContext(test_config.api_key)
     self.payment = self.p.get_payment_service().create(test_config.magic_token)
     self.subscription = self.p.get_subscription_service().create_with_amount(self.payment.id,
                                                                              TestSubscriptionService.amount,
                                                                              TestSubscriptionService.currency,
                                                                              TestSubscriptionService.interval)
class TestPreauthorizationService(unittest.TestCase):

    amount = '4200'
    currency = 'EUR'
    description = 'Test Python'

    def setUp(self):
        self.p = PaymillContext(api_key=test_config.api_key)
        self.preauthorization = self.p.get_preauthorization_service(
        ).create_with_token(
            token=test_config.magic_token,
            amount=TestPreauthorizationService.amount,
            currency=TestPreauthorizationService.currency,
            description=TestPreauthorizationService.description)

    def test_create_sets_amount(self):
        self.assertEqual(TestPreauthorizationService.amount,
                         self.preauthorization.amount)

    def test_create_sets_currency(self):
        self.assertEqual(TestPreauthorizationService.currency,
                         self.preauthorization.currency)

    def test_create_sets_description(self):
        self.assertEqual(TestPreauthorizationService.description,
                         self.preauthorization.description)
示例#13
0
class TestOfferService(unittest.TestCase):

    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.offer = None

    def tearDown(self):
        del self.p

    def test_create_offer_default(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH', 'My offer')
        self.assertEqual('My offer', o.name)

    def test_create_offer_with_trial_period(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH', 'My offer', 2)
        self.assertEqual(2, o.trial_period_days)

    def test_delete_offer(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH', 'My offer')
        self.assertIsInstance(self.p.get_offer_service().remove(o), Offer)
class TestRefundService(unittest.TestCase):

    amount = 4200
    currency = 'EUR'
    description = 'Test Python'

    def setUp(self):
        self.p = PaymillContext(api_key=test_config.api_key)

    def test_refund(self):
        transaction = self.p.get_transaction_service().create_with_token(token=test_config.magic_token,
                                                                         amount=TestRefundService.amount,
                                                                         currency=TestRefundService.currency,
                                                                         description=TestRefundService.description)


        refund = self.p.get_refund_service().refund_transaction(transaction_id=transaction.id,
                                                                amount=TestRefundService.amount)

        self.assertEqual(TestRefundService.amount, refund.amount)
class TestRefundService(unittest.TestCase):

    amount = 4200
    currency = 'EUR'
    description = 'Test Python'

    def setUp(self):
        self.p = PaymillContext(api_key=test_config.api_key)

    def test_refund(self):
        transaction = self.p.get_transaction_service().create_with_token(
            token=test_config.magic_token,
            amount=TestRefundService.amount,
            currency=TestRefundService.currency,
            description=TestRefundService.description)

        refund = self.p.get_refund_service().refund_transaction(
            transaction_id=transaction.id, amount=TestRefundService.amount)

        self.assertEqual(TestRefundService.amount, refund.amount)
class TestPaymentService(unittest.TestCase):
    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.payment = None

    def tearDown(self):
        del self.p

    def test_create_payment_with_token_default(self):
        p1 = self.p.get_payment_service().create(token=test_config.magic_token)
        self.assertEqual(None, p1.client)

    def test_create_payment_with_client(self):
        c = self.p.get_client_service().create()
        p1 = self.p.get_payment_service().create(token=test_config.magic_token,
                                                 client_id=c.id)

        self.assertEqual(c.id, p1.client.id)

    def test_delete_payment(self):
        p1 = self.p.get_payment_service().create(token=test_config.magic_token)
        self.assertIsInstance(self.p.get_payment_service().remove(p1), Payment)
示例#17
0
class TestOfferService(unittest.TestCase):
    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.offer = None

    def tearDown(self):
        del self.p

    def test_create_offer_default(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH',
                                              'My offer')
        self.assertEqual('My offer', o.name)

    def test_create_offer_with_trial_period(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH',
                                              'My offer', 2)
        self.assertEqual(2, o.trial_period_days)

    def test_delete_offer(self):
        o = self.p.get_offer_service().create(100, 'EUR', '1 MONTH',
                                              'My offer')
        self.assertIsInstance(self.p.get_offer_service().remove(o), Offer)
class TestPaymentService(unittest.TestCase):

    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.payment = None

    def tearDown(self):
        del self.p

    def test_create_payment_with_token_default(self):
        p1 = self.p.get_payment_service().create(token=test_config.magic_token)
        self.assertEqual(None, p1.client)

    def test_create_payment_with_client(self):
        c = self.p.get_client_service().create()
        p1 = self.p.get_payment_service().create(token=test_config.magic_token,
                                                 client_id=c.id)

        self.assertEqual(c.id, p1.client.id)

    def test_delete_payment(self):
        p1 = self.p.get_payment_service().create(token=test_config.magic_token)
        self.assertIsInstance(self.p.get_payment_service().remove(p1), Payment)
class TestPreauthorizationService(unittest.TestCase):

    amount = '4200'
    currency = 'EUR'
    description = 'Test Python'

    def setUp(self):
        self.p = PaymillContext(api_key=test_config.api_key)
        self.preauthorization = self.p.get_preauthorization_service().create_with_token(token=test_config.magic_token,
                                                                                        amount=TestPreauthorizationService.amount,
                                                                                        currency=TestPreauthorizationService.currency,
                                                                                        description=TestPreauthorizationService.description)

    def test_create_sets_amount(self):
        self.assertEqual(TestPreauthorizationService.amount, self.preauthorization.amount)

    def test_create_sets_currency(self):
        self.assertEqual(TestPreauthorizationService.currency, self.preauthorization.currency)

    def test_create_sets_description(self):
        self.assertEqual(TestPreauthorizationService.description, self.preauthorization.description)
 def setUp(self):
     self.p = PaymillContext(test_config.api_key)
     self.payment = None
示例#21
0
class TestSubscriptionService(unittest.TestCase):

    currency = 'EUR'
    interval = '2 DAY'
    amount = 4200
    sub_dict = {
        u'livemode': False,
        u'updated_at': 1409647372,
        u'currency': u'EUR',
        u'id': u'sub_edacd9959b10c8f6eb5d',
        u'is_canceled': False,
        u'next_capture_at': 1409820171,
        u'temp_amount': None,
        u'status': u'active',
        u'trial_start': None,
        u'offer': {
            u'subscription_count': {
                u'active': u'1',
                u'inactive': 0
            },
            u'name': u'',
            u'created_at': 1409647371,
            u'interval': u'2 DAY',
            u'updated_at': 1409647371,
            u'app_id': None,
            u'currency': u'EUR',
            u'amount': u'4200',
            u'trial_period_days': None,
            u'id': u'offer_bb33ea77b942f570997b'
        },
        u'app_id': None,
        u'trial_end': None,
        u'payment': {
            u'app_id': None,
            u'is_recurring': True,
            u'expire_month': u'12',
            u'country': None,
            u'created_at': 1409647371,
            u'updated_at': 1409647371,
            u'card_holder': u'',
            u'card_type': u'visa',
            u'last4': u'1111',
            u'is_usable_for_preauthorization': True,
            u'client': u'client_4b6fc054e35ba1548959',
            u'expire_year': u'2015',
            u'type': u'creditcard',
            u'id': u'pay_3dca8cabea90e752ed7be662'
        },
        u'is_deleted': False,
        u'name': u'',
        u'end_of_period': None,
        u'canceled_at': None,
        u'created_at': 1409647371,
        u'interval': u'2 DAY',
        u'amount': 4200,
        u'client': {
            u'description': None,
            u'payment': [u'pay_3dca8cabea90e752ed7be662'],
            u'created_at': 1409647371,
            u'updated_at': 1409647371,
            u'app_id': None,
            u'email': None,
            u'id': u'client_4b6fc054e35ba1548959',
            u'subscription': None
        },
        u'period_of_validity': None
    }

    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.payment = self.p.get_payment_service().create(
            test_config.magic_token)
        self.subscription = self.p.get_subscription_service(
        ).create_with_amount(self.payment.id, TestSubscriptionService.amount,
                             TestSubscriptionService.currency,
                             TestSubscriptionService.interval)

    def tearDown(self):
        del self.p, self.payment, self.subscription

    def test_serialize_subscription_to_dict(self):
        self.assertIsInstance(TestSubscriptionService.sub_dict, dict)

    def test_serialize_subscription_to_Subscription(self):
        s = Subscription(TestSubscriptionService.sub_dict)
        self.assertIsInstance(s, Subscription)
        self.assertEqual(1409647372, s.updated_at)

    def test_create_subscription_sets_client_id(self):
        self.assertIsNotNone(self.subscription.client.id)

    def test_subscription_create_sets_payment_id(self):
        self.assertEqual(self.payment.id, self.subscription.payment.id)

    def test_subscription_create_sets_amount(self):
        self.assertEqual(TestSubscriptionService.amount,
                         self.subscription.amount)

    def test_subscription_create_sets_currency(self):
        self.assertEqual(TestSubscriptionService.currency,
                         self.subscription.currency)

    def test_subscription_create_sets_interval(self):
        self.assertEqual(TestSubscriptionService.interval,
                         self.subscription.interval)

    def test_subscription_update_default_sets_interval(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id, TestSubscriptionService.amount,
            TestSubscriptionService.currency, TestSubscriptionService.interval)
        subscription.interval = '1 MONTH,FRIDAY'
        s = p.get_subscription_service().update(subscription)
        self.assertEqual('1 MONTH,FRIDAY', s.interval)

    def test_subscription_update_with_amount_sets_amount(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id, TestSubscriptionService.amount,
            TestSubscriptionService.currency, TestSubscriptionService.interval)
        subscription.amount = 5600
        s = p.get_subscription_service().update_with_amount(
            subscription, amount_change_type=1)
        self.assertEqual(5600, s.amount)

    def test_subscription_cancel(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id, TestSubscriptionService.amount,
            TestSubscriptionService.currency, TestSubscriptionService.interval)
        s = p.get_subscription_service().cancel(subscription)
        self.assertIsInstance(s, Subscription)
 def setUp(self):
     self.p = PaymillContext(api_key=test_config.api_key)
class TestSubscriptionService(unittest.TestCase):

    currency = 'EUR'
    interval = '2 DAY'
    amount = 4200
    sub_dict = {u'livemode': False,
                u'updated_at': 1409647372,
                u'currency': u'EUR',
                u'id': u'sub_edacd9959b10c8f6eb5d',
                u'is_canceled': False,
                u'next_capture_at': 1409820171,
                u'temp_amount': None,
                u'status': u'active',
                u'trial_start': None,
                u'offer': {u'subscription_count': {u'active': u'1', u'inactive': 0},
                           u'name': u'', u'created_at': 1409647371,
                           u'interval': u'2 DAY',
                           u'updated_at': 1409647371,
                           u'app_id': None,
                           u'currency': u'EUR',
                           u'amount': u'4200',
                           u'trial_period_days': None,
                           u'id': u'offer_bb33ea77b942f570997b'},
                u'app_id': None,
                u'trial_end': None,
                u'payment': {u'app_id': None,
                             u'is_recurring': True,
                             u'expire_month': u'12',
                             u'country': None,
                             u'created_at': 1409647371,
                             u'updated_at': 1409647371,
                             u'card_holder': u'',
                             u'card_type': u'visa',
                             u'last4': u'1111',
                             u'is_usable_for_preauthorization': True,
                             u'client': u'client_4b6fc054e35ba1548959',
                             u'expire_year': u'2015',
                             u'type': u'creditcard',
                             u'id': u'pay_3dca8cabea90e752ed7be662'},
                u'is_deleted': False,
                u'name': u'',
                u'end_of_period': None,
                u'canceled_at': None,
                u'created_at': 1409647371,
                u'interval': u'2 DAY',
                u'amount': 4200,
                u'client': {u'description': None,
                            u'payment': [u'pay_3dca8cabea90e752ed7be662'],
                            u'created_at': 1409647371,
                            u'updated_at': 1409647371,
                            u'app_id': None,
                            u'email': None,
                            u'id': u'client_4b6fc054e35ba1548959',
                            u'subscription': None},
                u'period_of_validity': None}

    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.payment = self.p.get_payment_service().create(test_config.magic_token)
        self.subscription = self.p.get_subscription_service().create_with_amount(self.payment.id,
                                                                                 TestSubscriptionService.amount,
                                                                                 TestSubscriptionService.currency,
                                                                                 TestSubscriptionService.interval)

    def tearDown(self):
        del self.p, self.payment, self.subscription

    def test_serialize_subscription_to_dict(self):
        self.assertIsInstance(TestSubscriptionService.sub_dict, dict)

    def test_serialize_subscription_to_Subscription(self):
        s = Subscription(TestSubscriptionService.sub_dict)
        self.assertIsInstance(s, Subscription)
        self.assertEqual(1409647372, s.updated_at)

    def test_create_subscription_sets_client_id(self):
        self.assertIsNotNone(self.subscription.client.id)

    def test_subscription_create_sets_payment_id(self):
        self.assertEqual(self.payment.id, self.subscription.payment.id)

    def test_subscription_create_sets_amount(self):
        self.assertEqual(TestSubscriptionService.amount, self.subscription.amount)

    def test_subscription_create_sets_currency(self):
        self.assertEqual(TestSubscriptionService.currency, self.subscription.currency)

    def test_subscription_create_sets_interval(self):
        self.assertEqual(TestSubscriptionService.interval, self.subscription.interval)

    def test_subscription_update_default_sets_interval(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                       TestSubscriptionService.amount,
                                                                       TestSubscriptionService.currency,
                                                                       TestSubscriptionService.interval)
        subscription.interval = '1 MONTH,FRIDAY'
        s = p.get_subscription_service().update(subscription)
        self.assertEqual('1 MONTH,FRIDAY', s.interval)

    def test_subscription_update_with_amount_sets_amount(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                       TestSubscriptionService.amount,
                                                                       TestSubscriptionService.currency,
                                                                       TestSubscriptionService.interval)
        subscription.amount = 5600
        s = p.get_subscription_service().update_with_amount(subscription, amount_change_type=1)
        self.assertEqual(5600, s.amount)

    def test_subscription_cancel(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(payment.id,
                                                                       TestSubscriptionService.amount,
                                                                       TestSubscriptionService.currency,
                                                                       TestSubscriptionService.interval)
        s = p.get_subscription_service().cancel(subscription)
        self.assertIsInstance(s, Subscription)
示例#24
0
 def setUp(self):
     TestRefundService.amount = test_config.get_next_amount()
     self.p = PaymillContext(api_key=test_config.api_key)
示例#25
0
 def setUp(self):
     self.p = PaymillContext(test_config.api_key)
     self.client = None
 def setUp(self):
     self.p = PaymillContext(api_key=test_config.api_key)
 def setUp(self):
     self.p = PaymillContext(api_key=test_config.api_key)
     self.preauthorization = self.p.get_preauthorization_service().create_with_token(token=test_config.magic_token,
                                                                                     amount=TestPreauthorizationService.amount,
                                                                                     currency=TestPreauthorizationService.currency,
                                                                                     description=TestPreauthorizationService.description)
示例#28
0
 def setUp(self):
     self.p = PaymillContext(test_config.api_key)
     self.offer = None
class TestSubscriptionService(unittest.TestCase):

    currency = "EUR"
    interval = "2 DAY"
    amount = 4200
    sub_dict = {
        u"livemode": False,
        u"updated_at": 1409647372,
        u"currency": u"EUR",
        u"id": u"sub_edacd9959b10c8f6eb5d",
        u"is_canceled": False,
        u"next_capture_at": 1409820171,
        u"temp_amount": None,
        u"status": u"active",
        u"trial_start": None,
        u"offer": {
            u"subscription_count": {u"active": u"1", u"inactive": 0},
            u"name": u"",
            u"created_at": 1409647371,
            u"interval": u"2 DAY",
            u"updated_at": 1409647371,
            u"app_id": None,
            u"currency": u"EUR",
            u"amount": u"4200",
            u"trial_period_days": None,
            u"id": u"offer_bb33ea77b942f570997b",
        },
        u"app_id": None,
        u"trial_end": None,
        u"payment": {
            u"app_id": None,
            u"is_recurring": True,
            u"expire_month": u"12",
            u"country": None,
            u"created_at": 1409647371,
            u"updated_at": 1409647371,
            u"card_holder": u"",
            u"card_type": u"visa",
            u"last4": u"1111",
            u"is_usable_for_preauthorization": True,
            u"client": u"client_4b6fc054e35ba1548959",
            u"expire_year": u"2015",
            u"type": u"creditcard",
            u"id": u"pay_3dca8cabea90e752ed7be662",
        },
        u"is_deleted": False,
        u"name": u"",
        u"end_of_period": None,
        u"canceled_at": None,
        u"created_at": 1409647371,
        u"interval": u"2 DAY",
        u"amount": 4200,
        u"client": {
            u"description": None,
            u"payment": [u"pay_3dca8cabea90e752ed7be662"],
            u"created_at": 1409647371,
            u"updated_at": 1409647371,
            u"app_id": None,
            u"email": None,
            u"id": u"client_4b6fc054e35ba1548959",
            u"subscription": None,
        },
        u"period_of_validity": None,
    }

    def setUp(self):
        self.p = PaymillContext(test_config.api_key)
        self.payment = self.p.get_payment_service().create(test_config.magic_token)
        self.subscription = self.p.get_subscription_service().create_with_amount(
            self.payment.id,
            TestSubscriptionService.amount,
            TestSubscriptionService.currency,
            TestSubscriptionService.interval,
        )

    def tearDown(self):
        del self.p, self.payment, self.subscription

    def test_serialize_subscription_to_dict(self):
        self.assertIsInstance(TestSubscriptionService.sub_dict, dict)

    def test_serialize_subscription_to_Subscription(self):
        s = Subscription(TestSubscriptionService.sub_dict)
        self.assertIsInstance(s, Subscription)
        self.assertEqual(1409647372, s.updated_at)

    def test_create_subscription_sets_client_id(self):
        self.assertIsNotNone(self.subscription.client.id)

    def test_subscription_create_sets_payment_id(self):
        self.assertEqual(self.payment.id, self.subscription.payment.id)

    def test_subscription_create_sets_amount(self):
        self.assertEqual(TestSubscriptionService.amount, self.subscription.amount)

    def test_subscription_create_sets_currency(self):
        self.assertEqual(TestSubscriptionService.currency, self.subscription.currency)

    def test_subscription_create_sets_interval(self):
        self.assertEqual(TestSubscriptionService.interval, self.subscription.interval)

    def test_subscription_update_default_sets_interval(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id,
            TestSubscriptionService.amount,
            TestSubscriptionService.currency,
            TestSubscriptionService.interval,
        )
        subscription.interval = "1 MONTH,FRIDAY"
        s = p.get_subscription_service().update(subscription)
        self.assertEqual("1 MONTH,FRIDAY", s.interval)

    def test_subscription_update_with_amount_sets_amount(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id,
            TestSubscriptionService.amount,
            TestSubscriptionService.currency,
            TestSubscriptionService.interval,
        )
        subscription.amount = 5600
        s = p.get_subscription_service().update_with_amount(subscription, amount_change_type=1)
        self.assertEqual(5600, s.amount)

    def test_subscription_cancel(self):
        p = PaymillContext(test_config.api_key)
        payment = p.get_payment_service().create(test_config.magic_token)
        subscription = p.get_subscription_service().create_with_amount(
            payment.id,
            TestSubscriptionService.amount,
            TestSubscriptionService.currency,
            TestSubscriptionService.interval,
        )
        s = p.get_subscription_service().cancel(subscription)
        self.assertIsInstance(s, Subscription)