# Path: patchwork/tests/browser.py
# class SeleniumTestCase(StaticLiveServerTestCase):
#     _SCREENSHOT_DIR = os.path.dirname(__file__) + '/../../selenium_screenshots'
# 
#     def setUp(self):
#         self.skip = os.getenv('PATCHWORK_SKIP_BROWSER_TESTS', None)
#         if self.skip:
#             self.skipTest("Disabled by environment variable")
# 
#         super(SeleniumTestCase, self).setUp()
# 
#         self.browser = os.getenv('SELENIUM_BROWSER', 'chrome')
#         if self.browser == 'firefox':
#             self.selenium = webdriver.Firefox()
#         if self.browser == 'chrome':
#             options = webdriver.ChromeOptions()
#             options.add_argument("--no-sandbox")
#             options.set_headless(True)
#             self.selenium = webdriver.Chrome(
#                 service_args=["--verbose", "--log-path=selenium.log"],
#                 options=options
#             )
# 
#         mkdir(self._SCREENSHOT_DIR)
#         self._screenshot_number = 1
# 
#     def tearDown(self):
#         self.selenium.quit()
#         super(SeleniumTestCase, self).tearDown()
# 
#     def screenshot(self):
#         name = "%s_%d.png" % (self._testMethodName, self._screenshot_number)
#         path = os.path.join(self._SCREENSHOT_DIR, name)
#         self.selenium.get_screenshot_as_file(path)
#         self._screenshot_number += 1
# 
#     def get(self, relative_url):
#         self.selenium.get('%s%s' % (self.live_server_url, relative_url))
#         self.screenshot()
# 
#     def find(self, selector):
#         return self.selenium.find_element_by_css_selector(selector)
# 
#     def focused_element(self):
#         active_element = self.selenium.switch_to.active_element
#         # XXX: WA for Firefox driver
#         #      selenium does not perform w3c conformance negotiation
#         #      resulting in focused element being wrapped in a dict
#         if isinstance(active_element, dict):
#             active_element = active_element['value']
#         return active_element
# 
#     def wait_until_present(self, name):
#         def is_present(driver):
#             return driver.find_element_by_name(name)
#         msg = "An element named '%s' should be on the page" % name
#         element = Wait(self.selenium).until(is_present, msg)
#         self.screenshot()
#         return element
# 
#     def wait_until_visible(self, selector):
#         def is_visible(driver):
#             return self.find(selector).is_displayed()
#         msg = "The element matching '%s' should be visible" % selector
#         Wait(self.selenium).until(is_visible, msg)
#         self.screenshot()
#         return self.find(selector)
# 
#     def wait_until_focused(self, selector):
#         def is_focused(driver):
#             return self.find(selector) == self.focused_element()
#         msg = "The element matching '%s' should be focused" % selector
#         Wait(self.selenium).until(is_focused, msg)
#         self.screenshot()
#         return self.find(selector)
# 
#     def enter_text(self, name, value):
#         field = self.wait_until_present(name)
#         field.send_keys(value)
#         return field
# 
#     def click(self, selector):
#         element = self.wait_until_visible(selector)
#         element.click()
#         return element
# 
# Path: patchwork/tests/test_user.py
# class TestUser(object):
# 
#     def __init__(self, username='testuser', email='test@example.com',
#                  secondary_email='test2@example.com'):
#         self.username = username
#         self.email = email
#         self.secondary_email = secondary_email
#         self.password = User.objects.make_random_password()
#         self.user = User.objects.create_user(
#             self.username, self.email, self.password)
# 
#     def basic_auth_header(self):
#         userpass = ("%s:%s" % (self.username, self.password)).encode('utf-8')
#         return 'Basic ' + base64.b64encode(userpass).decode('utf-8')
# 
#     def add_to_maintainers(self, project):
#         profile = self.user.profile
#         profile.maintainer_projects.add(project)
#         profile.save()


from patchwork.tests.browser import SeleniumTestCase
from patchwork.tests.test_user import TestUser
# Patchwork - automated patch tracking system
# Copyright (C) 2015 Intel Corporation
#
# This file is part of the Patchwork package.
#
# Patchwork is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Patchwork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



class LoginTestCase(SeleniumTestCase):

    def setUp(self):
        super(LoginTestCase, self).setUp()

# Path: patchwork/tests/browser.py
# class SeleniumTestCase(StaticLiveServerTestCase):
#     _SCREENSHOT_DIR = os.path.dirname(__file__) + '/../../selenium_screenshots'
# 
#     def setUp(self):
#         self.skip = os.getenv('PATCHWORK_SKIP_BROWSER_TESTS', None)
#         if self.skip:
#             self.skipTest("Disabled by environment variable")
# 
#         super(SeleniumTestCase, self).setUp()
# 
#         self.browser = os.getenv('SELENIUM_BROWSER', 'chrome')
#         if self.browser == 'firefox':
#             self.selenium = webdriver.Firefox()
#         if self.browser == 'chrome':
#             options = webdriver.ChromeOptions()
#             options.add_argument("--no-sandbox")
#             options.set_headless(True)
#             self.selenium = webdriver.Chrome(
#                 service_args=["--verbose", "--log-path=selenium.log"],
#                 options=options
#             )
# 
#         mkdir(self._SCREENSHOT_DIR)
#         self._screenshot_number = 1
# 
#     def tearDown(self):
#         self.selenium.quit()
#         super(SeleniumTestCase, self).tearDown()
# 
#     def screenshot(self):
#         name = "%s_%d.png" % (self._testMethodName, self._screenshot_number)
#         path = os.path.join(self._SCREENSHOT_DIR, name)
#         self.selenium.get_screenshot_as_file(path)
#         self._screenshot_number += 1
# 
#     def get(self, relative_url):
#         self.selenium.get('%s%s' % (self.live_server_url, relative_url))
#         self.screenshot()
# 
#     def find(self, selector):
#         return self.selenium.find_element_by_css_selector(selector)
# 
#     def focused_element(self):
#         active_element = self.selenium.switch_to.active_element
#         # XXX: WA for Firefox driver
#         #      selenium does not perform w3c conformance negotiation
#         #      resulting in focused element being wrapped in a dict
#         if isinstance(active_element, dict):
#             active_element = active_element['value']
#         return active_element
# 
#     def wait_until_present(self, name):
#         def is_present(driver):
#             return driver.find_element_by_name(name)
#         msg = "An element named '%s' should be on the page" % name
#         element = Wait(self.selenium).until(is_present, msg)
#         self.screenshot()
#         return element
# 
#     def wait_until_visible(self, selector):
#         def is_visible(driver):
#             return self.find(selector).is_displayed()
#         msg = "The element matching '%s' should be visible" % selector
#         Wait(self.selenium).until(is_visible, msg)
#         self.screenshot()
#         return self.find(selector)
# 
#     def wait_until_focused(self, selector):
#         def is_focused(driver):
#             return self.find(selector) == self.focused_element()
#         msg = "The element matching '%s' should be focused" % selector
#         Wait(self.selenium).until(is_focused, msg)
#         self.screenshot()
#         return self.find(selector)
# 
#     def enter_text(self, name, value):
#         field = self.wait_until_present(name)
#         field.send_keys(value)
#         return field
# 
#     def click(self, selector):
#         element = self.wait_until_visible(selector)
#         element.click()
#         return element
# 
# Path: patchwork/tests/test_user.py
# class TestUser(object):
# 
#     def __init__(self, username='testuser', email='test@example.com',
#                  secondary_email='test2@example.com'):
#         self.username = username
#         self.email = email
#         self.secondary_email = secondary_email
#         self.password = User.objects.make_random_password()
#         self.user = User.objects.create_user(
#             self.username, self.email, self.password)
# 
#     def basic_auth_header(self):
#         userpass = ("%s:%s" % (self.username, self.password)).encode('utf-8')
#         return 'Basic ' + base64.b64encode(userpass).decode('utf-8')
# 
#     def add_to_maintainers(self, project):
#         profile = self.user.profile
#         profile.maintainer_projects.add(project)
#         profile.save()


# Path: patchwork/tests/test_user_browser.py
from patchwork.tests.browser import SeleniumTestCase
from patchwork.tests.test_user import TestUser

# Patchwork - automated patch tracking system
# Copyright (C) 2015 Intel Corporation
#
# This file is part of the Patchwork package.
#
# Patchwork is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Patchwork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



class LoginTestCase(SeleniumTestCase):

    def setUp(self):
        super(LoginTestCase, self).setUp()

        self.user = TestUser()