コード例 #1
0
    def test_approve_request(self):
        # Create admin
        RegisterHelper.create_superuser()
        RegisterHelper.fill_login_form(self.selenium,
                                       self.login_url,
                                       admin=True)
        RegisterHelper.submit_login_form(self.selenium)

        # Create user
        user = RegisterHelper.create_user(approved=False)
        # Get EmailAddress URL
        email_obj = EmailAddress.objects.filter(user=user)[0]
        assert email_obj.admin_approval != 'approved', 'EmailAddress is already approved when created!'

        email_url = reverse('admin:account_emailaddress_change',
                            args=[email_obj.id])
        email_url = '%s%s' % (self.live_server_url, email_url)
        self.selenium.get(email_url)
        self.selenium.find_element_by_xpath(
            '//input[@name="_approve"]').click()
        self.assertEqual(self.selenium.current_url, email_url)

        # Reload email_obj
        email_obj = EmailAddress.objects.get(pk=email_obj.pk)
        self.assertEqual(email_obj.admin_approval, 'approved',
                         'Failed to approve EmailAddress')
コード例 #2
0
 def setUp(self):
     # Create the admin.
     RegisterHelper.create_superuser()
     # Launch a browser.
     self.browser = webdriver.Firefox()
     self.browser.implicitly_wait(SELENIUM_WEB_ELEMENT_PRESENCE_CHECK_TIMEOUT)
     # Log in.
     RegisterHelper.fill_login_form(
         selenium=self.browser,
         login_url="%s%s" % (self.live_server_url, reverse("account_login")),
         admin=True
     )
     RegisterHelper.submit_login_form(selenium=self.browser)
コード例 #3
0
 def setUp(self):
     # Create test data.
     self._set_up_test_data()
     # Create the admin.
     RegisterHelper.create_superuser()
     # Launch a browser.
     self.browser = webdriver.Firefox()
     self.browser.implicitly_wait(10)
     # Log in.
     RegisterHelper.fill_login_form(
         selenium=self.browser,
         login_url="%s%s" % (self.live_server_url, reverse("account_login")),
         admin=True
     )
     RegisterHelper.submit_login_form(selenium=self.browser)
コード例 #4
0
    def test_reject_request(self):
        # Create admin
        RegisterHelper.create_superuser()
        RegisterHelper.fill_login_form(self.selenium,
                                       self.login_url,
                                       admin=True)
        RegisterHelper.submit_login_form(self.selenium)

        # Create user
        user = RegisterHelper.create_user(approved=False)
        # Get EmailAddress URL
        email_obj = EmailAddress.objects.filter(user=user)[0]
        assert email_obj.admin_approval != 'rejected', 'EmailAddress is already rejected when created!'

        email_url = reverse('admin:account_emailaddress_change',
                            args=[email_obj.id])
        email_url = '%s%s' % (self.live_server_url, email_url)
        self.selenium.get(email_url)

        # show rejection popup
        self.selenium.find_element_by_xpath(
            '//button[@name="_reject"]').click()

        # wait for popup
        reject_textarea = WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located((By.ID, "reject_reason_text")))

        reject_button = self.selenium.find_element_by_xpath(
            '//input[@name="_reject"]')
        self.assertFalse(
            reject_button.is_enabled(),
            'Reject button is enabled even though reject reason is empty')

        reject_reason = "These are more than 15 characters"
        reject_textarea.send_keys(reject_reason)
        self.assertTrue(
            reject_button.is_enabled(),
            'Reject button is disabled even after filling reject reason')

        reject_button.click()
        self.assertEqual(self.selenium.current_url, email_url)

        # Reload email_obj
        email_obj = EmailAddress.objects.get(pk=email_obj.pk)
        self.assertEqual(email_obj.admin_approval, 'rejected',
                         'Failed to reject EmailAddress')
        self.assertEqual(email_obj.reject_reason, reject_reason,
                         'Failed to update reject reason')
コード例 #5
0
    def setUp(self):
        # Create the admin.
        RegisterHelper.create_superuser()

        # Launch a browser.
        self.browser = webdriver.Firefox()

        # Log in.
        RegisterHelper.fill_login_form(
            selenium=self.browser,
            login_url="%s%s" %
            (self.live_server_url, reverse("account_login")),
            admin=True)
        RegisterHelper.submit_login_form(selenium=self.browser)

        # Call the setUp() of parent class.
        super(KeywordManagement, self).setUp()