<commit_before>import random
# The string module is not deprecated. This is a bug in Pylint: https://www.logilab.org/ticket/2481.
import string  # pylint: disable=deprecated-module

from bok_choy.javascript import wait_for_js
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from acceptance_tests.config import VERIFIED_COURSE_ID
from acceptance_tests.constants import DEFAULT_END_DATE, DEFAULT_START_DATE
from acceptance_tests.pages.ecommerce import EcommerceAppPage


def _get_coupon_name(is_discount):
    """ Returns an appropriate coupon name. """
    prefix = 'test-discount-code-' if is_discount else 'test-enrollment-code-'
    postfix = ''.join(random.choice(string.ascii_letters) for _ in range(3))

    return prefix + postfix


class BasketPage(EcommerceAppPage):
    path = 'basket'

    def is_browser_on_page(self):
        return self.browser.title.startswith('Basket')


class CouponsCreatePage(EcommerceAppPage):
    path = 'coupons/new'

    def is_browser_on_page(self):
        return self.q(css='form.coupon-form-view').visible

    @wait_for_js
    def fill_create_coupon_form(self, is_discount):
        """ Fills the coupon form with test data and creates the coupon.

        Args:
            is_discount(bool): Indicates if the code that's going to be created
                               should be a discount or enrollment coupon code.

        Returns:
            coupon_name(str): Fuzzied name of the coupon that has been created.

        """
        course_id_input = 'input[name="course_id"]'
        coupon_name = _get_coupon_name(is_discount)
        self.q(css='input[name="title"]').fill(coupon_name)
        self.q(css=course_id_input).fill(VERIFIED_COURSE_ID)
        self.wait_for_ajax()
        self.wait_for_element_presence(
            'select[name="seat_type"] option[value="Verified"]',
            'Seat Type Drop-Down List is Present'
        )

        self.q(css="input[name='start_date']").fill(str(DEFAULT_START_DATE))
        self.q(css="input[name='end_date']").fill(str(DEFAULT_END_DATE))
        self.q(css="input[name='client_username']").fill('Test Client')<commit_msg>Fix the field name in the coupon form<commit_after>import random
# The string module is not deprecated. This is a bug in Pylint: https://www.logilab.org/ticket/2481.
import string  # pylint: disable=deprecated-module

from bok_choy.javascript import wait_for_js
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from acceptance_tests.config import VERIFIED_COURSE_ID
from acceptance_tests.constants import DEFAULT_END_DATE, DEFAULT_START_DATE
from acceptance_tests.pages.ecommerce import EcommerceAppPage


def _get_coupon_name(is_discount):
    """ Returns an appropriate coupon name. """
    prefix = 'test-discount-code-' if is_discount else 'test-enrollment-code-'
    postfix = ''.join(random.choice(string.ascii_letters) for _ in range(3))

    return prefix + postfix


class BasketPage(EcommerceAppPage):
    path = 'basket'

    def is_browser_on_page(self):
        return self.browser.title.startswith('Basket')


class CouponsCreatePage(EcommerceAppPage):
    path = 'coupons/new'

    def is_browser_on_page(self):
        return self.q(css='form.coupon-form-view').visible

    @wait_for_js
    def fill_create_coupon_form(self, is_discount):
        """ Fills the coupon form with test data and creates the coupon.

        Args:
            is_discount(bool): Indicates if the code that's going to be created
                               should be a discount or enrollment coupon code.

        Returns:
            coupon_name(str): Fuzzied name of the coupon that has been created.

        """
        course_id_input = 'input[name="course_id"]'
        coupon_name = _get_coupon_name(is_discount)
        self.q(css='input[name="title"]').fill(coupon_name)
        self.q(css=course_id_input).fill(VERIFIED_COURSE_ID)
        self.wait_for_ajax()
        self.wait_for_element_presence(
            'select[name="seat_type"] option[value="Verified"]',
            'Seat Type Drop-Down List is Present'
        )

        self.q(css="input[name='start_date']").fill(str(DEFAULT_START_DATE))
        self.q(css="input[name='end_date']").fill(str(DEFAULT_END_DATE))
        self.q(css="input[name='client']").fill('Test Client')
{'fraction_non_alphanumeric': 0.10064287297716693, 'fraction_numerical': 0.0022168033695411215, 'mean_word_length': 3.594704684317719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6697986', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1389, 'n_words': 310}