diff --git a/orchestra/utils/tests.py b/orchestra/utils/tests.py index ae79ee41..36f8c036 100644 --- a/orchestra/utils/tests.py +++ b/orchestra/utils/tests.py @@ -17,7 +17,7 @@ from .python import random_ascii class AppDependencyMixin(object): DEPENDENCIES = () - + @classmethod def setUpClass(cls): current_app = cls.__module__.split('.tests.')[0] @@ -70,13 +70,13 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase): cls.vdisplay.start() cls.selenium = WebDriver() super(BaseLiveServerTestCase, cls).setUpClass() - + @classmethod def tearDownClass(cls): cls.selenium.quit() cls.vdisplay.stop() super(BaseLiveServerTestCase, cls).tearDownClass() - + def create_account(self, username='', superuser=False): if not username: username = '%s_superaccount' % random_ascii(5) @@ -85,14 +85,14 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase): if superuser: return Account.objects.create_superuser(username, password=password, email='orchestra@orchestra.org') return Account.objects.create_user(username, password=password, email='orchestra@orchestra.org') - + def setUp(self): from orm.api import Api super(BaseLiveServerTestCase, self).setUp() self.rest = Api(self.live_server_url + '/api/') self.rest.enable_logging() self.account = self.create_account(superuser=True) - + def admin_login(self): # Original option session = SessionStore() @@ -112,16 +112,16 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase): # self.selenium.find_element_by_id("id_username").send_keys(self.account.username) # self.selenium.find_element_by_id("id_password").send_keys(self.account_password) # self.selenium.find_element_by_css_selector("input[type='submit']").click() - + def rest_login(self): self.rest.login(username=self.account.username, password=self.account_password) - + def take_screenshot(self): timestamp = datetime.datetime.now().isoformat().replace(':', '') filename = 'screenshot_%s_%s.png' % (self.id(), timestamp) - path = '/home/orchestra/snapshots' + path = settings.BASE_DIR self.selenium.save_screenshot(os.path.join(path, filename)) - + def admin_delete(self, obj): opts = obj._meta app_label, model_name = opts.app_label, opts.model_name @@ -131,7 +131,7 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase): confirmation = self.selenium.find_element_by_name('post') confirmation.submit() self.assertNotEqual(url, self.selenium.current_url) - + def admin_disable(self, obj): opts = obj._meta app_label, model_name = opts.app_label, opts.model_name @@ -143,20 +143,20 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase): save = self.selenium.find_element_by_name('_save') save.submit() self.assertNotEqual(url, self.selenium.current_url) - + def admin_change_password(self, obj, password): opts = obj._meta app_label, model_name = opts.app_label, opts.model_name change_password = reverse('admin:%s_%s_change_password' % (app_label, model_name), args=(obj.pk,)) url = self.live_server_url + change_password self.selenium.get(url) - + password_field = self.selenium.find_element_by_id('id_password1') password_field.send_keys(password) password_field = self.selenium.find_element_by_id('id_password2') password_field.send_keys(password) password_field.submit() - + self.assertNotEqual(url, self.selenium.current_url) def snapshot_on_error(test):