accept empty cover in document save form
[redakcja.git] / tests / integration / base.py
index c2774c9..d243eb3 100644 (file)
@@ -1,15 +1,18 @@
+# -*- coding: utf-8 -*-\r
+#\r
+# This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.\r
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.\r
+#\r
 import os\r
 import inspect\r
-from urlparse import urlparse\r
 \r
 from django.test import LiveServerTestCase\r
 from django.test.client import Client\r
 from django.conf import settings\r
-from django.contrib.auth.models import User, Permission\r
+from django.contrib.auth.models import User\r
 from django.utils.translation import ugettext as _\r
 \r
-from selenium import webdriver, selenium\r
-from selenium.webdriver.support.wait import WebDriverWait\r
+from selenium import webdriver\r
 \r
 \r
 class SeleniumTestCase(LiveServerTestCase):\r
@@ -28,7 +31,7 @@ class SeleniumTestCase(LiveServerTestCase):
     def setUp(self):\r
         self.browser.delete_all_cookies()\r
     \r
-    def create_user(self, username = 'testuser',  passwd = 'passwd', do_login = False):\r
+    def create_user(self, username='testuser',  passwd='passwd', do_login=False):\r
         user = User.objects.create_user(username, '', passwd)\r
         user._plain_passwd = passwd\r
         if do_login:\r
@@ -43,17 +46,16 @@ class SeleniumTestCase(LiveServerTestCase):
         \r
     def login_user(self, user):\r
         client = Client()\r
-        client.login(username = user.username, password = user._plain_passwd)\r
+        client.login(username=user.username, password=user._plain_passwd)\r
 \r
         if not self.browser.current_url.startswith(self.live_server_url):\r
             self.browser.get(self.live_server_url+'/not_existing_url')\r
             \r
-        self.browser.find_element_by_tag_name('body') # Make sure the page is actually loaded before setting the cookie\r
+        self.browser.find_element_by_tag_name('body')  # Make sure the page is actually loaded before setting the cookie\r
         self.browser.delete_cookie(settings.SESSION_COOKIE_NAME)\r
-        self.browser.add_cookie(dict(name = settings.SESSION_COOKIE_NAME, \r
-                                     value = client.cookies[settings.SESSION_COOKIE_NAME].value,\r
-                                     path = '/')\r
-                               )\r
+        self.browser.add_cookie(dict(name=settings.SESSION_COOKIE_NAME,\r
+                                     value=client.cookies[settings.SESSION_COOKIE_NAME].value,\r
+                                     path='/'))\r
         \r
     def get_main_page(self):\r
         self.browser.get(self.live_server_url)\r
@@ -82,7 +84,7 @@ class MainPage(Page):
                 a.click()\r
                 self.tab = find_tab_class(tab_title)(self.browser)\r
                 return\r
-        raise Exception, 'Tab not found'\r
+        raise Exception('Tab not found')\r
         \r
                 \r
 def find_tab_class(tab_title):       \r
@@ -121,5 +123,3 @@ class BooksListPage(MainPageTabBase):
     @property\r
     def visible_books_count(self):\r
         return len(self.element.find_element_by_id('file-list').find_elements_by_tag_name('tr')) - 2\r
-        \r
-        
\ No newline at end of file