<commit_before>from .base import FunctionalTest

class RegistrationTest(FunctionalTest):

    def test_can_register(self):
        # Jonas geht auf getraenkewart.de
        self.browser.get(self.server_url)

        # Jonas möchte sich registrieren und klickt dazu auf Login
        self.browser.find_element_by_id("login-dropdown-button").click()
        # Er sieht einen Registrierungslink und clickt drauf
        self.browser.find_element_by_link_text("Registrieren").click()

        #Er gibt seine Daten ein
        self.browser.find_element_by_id("id_first_name").send_keys("Jonas")
        self.browser.find_element_by_id("id_last_name").send_keys("Schmidt")
        self.browser.find_element_by_id("id_email").send_keys("<EMAIL>")
        self.browser.find_element_by_id("id_username").send_keys("jonny")
        self.browser.find_element_by_id("id_password").send_keys("<PASSWORD>")
        self.browser.find_element_by_id("id_password2").send_keys("<PASSWORD>")

        # Er schickt seine Registrierung ab
        self.browser.find_element_by_id("register-button").click()

        # ... und erhält eine Bestätigung
        self.assertIn("erfolgreich angelegt", self.browser.find_element_by_class_name("alert").text)

    def test_register_error_keeps_data(self):
        first_name = "Jonas"
        last_name = "Schmidt"
        email = "<EMAIL>"
        username = "jonny"
        password = "<PASSWORD>"
        # Jonas möchte sich registrieren
        self.browser.get(self.server_url + "/register/")

        #Er gibt seine Daten ein
        first_name_input = self.browser.find_element_by_id("id_first_name")
        first_name_input.send_keys(first_name)
        last_name_input = self.browser.find_element_by_id("id_last_name")
        last_name_input.send_keys(last_<PASSWORD>)
        email_input = self.browser.find_element_by_id("id_email")
        email_input.send_keys(email)
        username_input = self.browser.find_element_by_id("id_username")
        username_input.send_keys(username)
        password_input = self.browser.find_element_by_id("id_password")
        password_input.send_keys(password)
        password_input2 = self.browser.find_element_by_id("id_password2")
        password_input2.send_keys(password)

        # Er schickt seine Registrierung ab
        self.browser.find_element_by_id("register-button").click()

        # ...stellt jedoch fest, dass sein Passwort zu kurz ist
        self.assertIn("muss mindestens 8 Zeichen lang sein", self.browser.find_element_by_class_name("alert").text)

        # zum Glück sind seine Daten noch da
        first_name_input = self.browser.find_element_by_id("id_first_name")
        self.assertEqual(first_name_input.get_attribute("value"), first_name)
        last_name_input = self.browser.find_element_by_id("id_last_name")
        self.assertEqual(last_name_input.get_attribute("value"), last_name)
        email_input = self.browser.find_element_by_id("id_email")
        self.assertEqual(email_input.get_attribute("value"), email)
        username_input = self.browser.find_element_by_id("id_username")
        self.assertEqual(username_input.get_attribute("value"), username)
        password_input = self.browser.find_element_by_id("id_password")
        self.assertEqual(password_input.get_attribute("value"), password)
        password_input2 = self.browser.find_element_by_id("id_password2")
        self.assertEqual(password_input.get_attribute("value"), password)<commit_msg>Since passwords don't get saved, don't test for it.<commit_after>from .base import FunctionalTest

class RegistrationTest(FunctionalTest):

    def test_can_register(self):
        # Jonas geht auf getraenkewart.de
        self.browser.get(self.server_url)

        # Jonas möchte sich registrieren und klickt dazu auf Login
        self.browser.find_element_by_id("login-dropdown-button").click()
        # Er sieht einen Registrierungslink und clickt drauf
        self.browser.find_element_by_link_text("Registrieren").click()

        #Er gibt seine Daten ein
        self.browser.find_element_by_id("id_first_name").send_keys("Jonas")
        self.browser.find_element_by_id("id_last_name").send_keys("Schmidt")
        self.browser.find_element_by_id("id_email").send_keys("<EMAIL>")
        self.browser.find_element_by_id("id_username").send_keys("jonny")
        self.browser.find_element_by_id("id_password").send_keys("<PASSWORD>")
        self.browser.find_element_by_id("id_password2").send_keys("<PASSWORD>")

        # Er schickt seine Registrierung ab
        self.browser.find_element_by_id("register-button").click()

        # ... und erhält eine Bestätigung
        self.assertIn("erfolgreich angelegt", self.browser.find_element_by_class_name("alert").text)

    def test_register_error_keeps_data(self):
        first_name = "Jonas"
        last_name = "Schmidt"
        email = "<EMAIL>"
        username = "jonny"
        password = "<PASSWORD>"
        # Jonas möchte sich registrieren
        self.browser.get(self.server_url + "/register/")

        #Er gibt seine Daten ein
        first_name_input = self.browser.find_element_by_id("id_first_name")
        first_name_input.send_keys(first_name)
        last_name_input = self.browser.find_element_by_id("id_last_name")
        last_name_input.send_keys(last_<PASSWORD>)
        email_input = self.browser.find_element_by_id("id_email")
        email_input.send_keys(email)
        username_input = self.browser.find_element_by_id("id_username")
        username_input.send_keys(username)
        password_input = self.browser.find_element_by_id("id_password")
        password_input.send_keys(password)
        password_input2 = self.browser.find_element_by_id("id_password2")
        password_input2.send_keys(password)

        # Er schickt seine Registrierung ab
        self.browser.find_element_by_id("register-button").click()

        # ...stellt jedoch fest, dass sein Passwort zu kurz ist
        self.assertIn("muss mindestens 8 Zeichen lang sein", self.browser.find_element_by_class_name("alert").text)

        # zum Glück sind seine Daten noch da
        first_name_input = self.browser.find_element_by_id("id_first_name")
        self.assertEqual(first_name_input.get_attribute("value"), first_name)
        last_name_input = self.browser.find_element_by_id("id_last_name")
        self.assertEqual(last_name_input.get_attribute("value"), last_name)
        email_input = self.browser.find_element_by_id("id_email")
        self.assertEqual(email_input.get_attribute("value"), email)
        username_input = self.browser.find_element_by_id("id_username")
        self.assertEqual(username_input.get_attribute("value"), username)
        # mit Ausnahme der Passwörter
        password_input = self.browser.find_element_by_id("id_password")
        self.assertEqual(password_input.get_attribute("value"), "")
        password_input2 = self.browser.find_element_by_id("id_password2")
        self.assertEqual(password_input.get_attribute("value"), "")
{'fraction_non_alphanumeric': 0.10438621475363144, 'fraction_numerical': 0.0019937339789233835, 'mean_word_length': 3.7549085985104944, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2394404', 'n_tokens_mistral': 2189, 'n_tokens_neox': 2176, 'n_words': 307}