<commit_before>from apps.cowry import factory, payments
from django.test.testcases import TestCase
import requests


# TODO Only run these tests when online and the merchant account / password is set.
class DocDataPaymentTests(TestCase):

    def setUp(self):
        self.payment = factory.create_payment_object('MASTERCARD', amount=2000, currency='EUR')
        self.payment.country = 'NL'
        self.payment.city = 'Amsterdam'
        self.payment.street = 'Dam'
        self.payment.postal_code = '1001AM'
        self.payment.first_name = 'Nijntje'
        self.payment.last_name = '<NAME>'
        self.payment.email = '<EMAIL>'
        self.payment.save()
        payments.create_remote_payment_order(self.payment)

    def test_setup_payment(self):
        self.assertTrue(self.payment.payment_order_key)

    def test_setup_payment_url(self):
        payment_url = payments.get_payment_url(self.payment)
        response = requests.get(payment_url)
        self.assertEqual(response.status_code, 200)
<commit_msg>Only run docdata tests with auth info or online.<commit_after>from apps.cowry import factory, payments
from django.conf import settings
from django.test.testcases import TestCase
from django.utils import unittest
import requests
from requests.exceptions import ConnectionError


try:
    getattr(settings, 'DOCDATA_MERCHANT_NAME')
    getattr(settings, 'DOCDATA_MERCHANT_PASSWORD')
    requests.get('http://www.google.com')
    run_docdata_tests = True
except (ConnectionError, AttributeError):
    run_docdata_tests = False


class DocDataPaymentTests(TestCase):

    def setUp(self):
        if run_docdata_tests:
            self.payment = factory.create_payment_object('MASTERCARD', amount=2000, currency='EUR')
            self.payment.country = 'NL'
            self.payment.city = 'Amsterdam'
            self.payment.street = 'Dam'
            self.payment.postal_code = '1001AM'
            self.payment.first_name = 'Nijntje'
            self.payment.last_name = '<NAME>'
            self.payment.email = '<EMAIL>'
            self.payment.save()
            payments.create_remote_payment_order(self.payment)

    @unittest.skipUnless(run_docdata_tests, 'DocData credentials not set or not online')
    def test_setup_payment(self):
        self.assertTrue(self.payment.payment_order_key)

    @unittest.skipUnless(run_docdata_tests, 'DocData credentials not set or not online')
    def test_setup_payment_url(self):
        payment_url = payments.get_payment_url(self.payment)
        response = requests.get(payment_url)
        self.assertEqual(response.status_code, 200)

{'fraction_non_alphanumeric': 0.09386973180076628, 'fraction_numerical': 0.00842911877394636, 'mean_word_length': 3.403035413153457, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2458891', 'n_tokens_mistral': 779, 'n_tokens_neox': 751, 'n_words': 157}