def test_retrieve_token_details_invalid(): """Tests that dictionary is properly built.""" try: gateway.retrieve_token_details('1', '2') except helcim_exceptions.ProcessingError: assert True else: assert False
def test_retrieve_token_details_missing_customer_code(): """Tests that retrieval without customer code causes error.""" token = models.HelcimToken.objects.create(token='a', token_f4l4='11114444', customer_code='1') try: gateway.retrieve_token_details(token.id) except helcim_exceptions.ProcessingError as error: assert str(error) == ( 'Unable to retrieve token details for specified customer.') else: assert False
def test_retrieve_token_details_valid(): """Tests that dictionary is properly built.""" token_details = gateway.retrieve_token_details('1', '2') assert token_details['token'] == 'abcdefghijklmnopqrstuvw' assert token_details['token_f4l4'] == '11114444' assert token_details['customer_code'] == 'CST0001'
def test_retrieve_token_details_missing_user(django_user_model): """Tests that retrieval without user causes error (when added).""" user = django_user_model.objects.create_user(username='******', password='******') token = models.HelcimToken.objects.create(token='a', token_f4l4='11114444', django_user=user, customer_code='1') try: gateway.retrieve_token_details(token.id, customer_code='1') except helcim_exceptions.ProcessingError as error: assert str(error) == ( 'Unable to retrieve token details for specified customer.') else: assert False
def retrieve_token_details(token_id, customer): """Shortcut for retrieve_token_details from the Gateway module. Added as a convenience to allow access to core functions via the bridge module exclusively. """ return gateway.retrieve_token_details(token_id, customer)
def test_retrieve_token_details_customer_code_only(): """Tests that retrieval with customer code only works.""" token = models.HelcimToken.objects.create(token='a', token_f4l4='11114444', customer_code='1') token_details = gateway.retrieve_token_details(token.id, customer_code='1') assert token_details['token'] == 'a' assert token_details['token_f4l4'] == '11114444' assert token_details['django_user'] is None assert token_details['customer_code'] == '1'
def test_retrieve_token_details_with_user(django_user_model): """Tests that retrieval with customer code and user works.""" user = django_user_model.objects.create_user(username='******', password='******') token = models.HelcimToken.objects.create(token='a', token_f4l4='11114444', django_user=user, customer_code='1') token_details = gateway.retrieve_token_details(token.id, django_user=user, customer_code='1') assert token_details['token'] == 'a' assert token_details['token_f4l4'] == '11114444' assert token_details['django_user'] == user assert token_details['customer_code'] == '1'