コード例 #1
0
 def test_valid_environment(self, mock_request):
     """ Check errors are raised with no environments """
     mock_request.return_value = FakeResponse(200, self.response_data)
     with self.assertRaises(ConfigError):
         CustomerToken.create_from_card_token('1234',
                                              self.user,
                                              environment='test')
コード例 #2
0
 def test_response_error(self, mock_request):
     """ Validate generic error response """
     mock_request.return_value = FakeResponse(200, self.response_error)
     with self.assertRaises(PinError):
         CustomerToken.create_from_card_token('1234',
                                              self.user,
                                              environment='test')
コード例 #3
0
ファイル: models.py プロジェクト: ionata/django-pinpayments
 def test_response_error(self, mock_request):
     """ Validate generic error response """
     mock_request.return_value = FakeResponse(200, self.response_error)
     with self.assertRaises(PinError):
         CustomerToken.create_from_card_token(
             '1234', self.user, environment='test'
         )
コード例 #4
0
ファイル: models.py プロジェクト: ionata/django-pinpayments
 def test_host_set(self, mock_request):
     """ Check errors are raised when the host is not set """
     mock_request.return_value = FakeResponse(200, self.response_data)
     with self.assertRaises(ConfigError):
         CustomerToken.create_from_card_token(
             '1234', self.user, environment='test'
         )
コード例 #5
0
ファイル: models.py プロジェクト: ionata/django-pinpayments
 def test_default_environment(self):
     """
     Unset PIN_DEFAULT_ENVIRONMENT to test that the environment defaults
     to 'test'.
     """
     del settings.PIN_DEFAULT_ENVIRONMENT
     token = CustomerToken()
     token.user = User.objects.create()
     token.environment = None
     token.save()
     self.assertEqual(token.environment, 'test')
コード例 #6
0
 def test_response_success(self, mock_request):
     mock_request.return_value = FakeResponse(200, self.response_data)
     customer = CustomerToken.create_from_card_token('1234',
                                                     self.user,
                                                     environment='test')
     self.assertIsInstance(customer, CustomerToken)
     self.assertEqual(customer.user, self.user)
     self.assertEqual(customer.token, '1234')
     self.assertEqual(customer.environment, 'test')
     self.assertEqual(customer.card_number, 'XXXX-XXXX-XXXX-0000')
     self.assertEqual(customer.card_type, 'master')
コード例 #7
0
ファイル: models.py プロジェクト: ionata/django-pinpayments
 def test_response_success(self, mock_request):
     """ Validate successful response """
     mock_request.return_value = FakeResponse(200, self.response_data)
     customer = CustomerToken.create_from_card_token(
         '1234', self.user, environment='test'
     )
     self.assertIsInstance(customer, CustomerToken)
     self.assertEqual(customer.user, self.user)
     self.assertEqual(customer.token, '1234')
     self.assertEqual(customer.environment, 'test')
     self.assertEqual(customer.cards.all()[0].display_number, 'XXXX-XXXX-XXXX-0000')
     self.assertEqual(customer.cards.all()[0].scheme, 'master')
コード例 #8
0
 def test_default_environment(self):
     # Unset PIN_DEFAULT_ENVIRONMENT to test that the environment defaults
     # to 'test'.
     del settings.PIN_DEFAULT_ENVIRONMENT
     token = CustomerToken()
     token.user = User.objects.create()
     token.environment = None
     token.save()
     self.assertEqual(token.environment, 'test')
コード例 #9
0
 def test_default_environment(self, mock_request):
     """ return a default environment """
     mock_request.return_value = FakeResponse(200, self.response_data)
     token = CustomerToken.create_from_card_token('1234', self.user)
     self.assertEqual(token.environment, 'test')
コード例 #10
0
 def test_secret_set(self, mock_request):
     mock_request.return_value = FakeResponse(200, self.response_data)
     with self.assertRaises(ConfigError):
         CustomerToken.create_from_card_token('1234',
                                              self.user,
                                              environment='test')
コード例 #11
0
 def test_response_not_json(self, mock_request):
     mock_request.return_value = FakeResponse(200, '')
     with self.assertRaises(PinError):
         CustomerToken.create_from_card_token('1234',
                                              self.user,
                                              environment='test')
コード例 #12
0
ファイル: models.py プロジェクト: ionata/django-pinpayments
 def test_default_environment(self, mock_request):
     """ return a default environment """
     mock_request.return_value = FakeResponse(200, self.response_data)
     token = CustomerToken.create_from_card_token('1234', self.user)
     self.assertEqual(token.environment, 'test')