-
-
Save rakeshsukla53/4f3abceac47c5ca7ca41 to your computer and use it in GitHub Desktop.
test permission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyLiveServerTestCase(LiveServerTestCase): | |
fixtures = [{"fields": {"username": "rakesh", "first_name": "", "last_name": "", "is_active": True, "is_superuser": True, "is_staff": True, "last_login": "2015-10-17T20:20:37.455Z", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$20000$1tGw8u4pGPxD$WmJVx9QDjFx0xZHq5vt/XgPXjYYvRn2tARyTzQ6RRYg=", "email": "rrs402@nyu.edu", "date_joined": "2015-10-06T19:02:04.044Z"}, "model": "auth.user", "pk": 1}] | |
def _fixture_setup(self): | |
# disable loading fixtures and flushing database before each test | |
print "MyLiveServerTestCase._fixture_setup: ignored" | |
def _fixture_teardown(self): | |
# disable loading fixtures and flushing database before each test | |
print "MyLiveServerTestCase._fixture_teardown: ignored" | |
def setUp(self): | |
super(MyLiveServerTestCase, self).setUp() | |
# self.display = Xvfb(width=800, height=600) | |
# self.display.start() | |
self.client = Client() | |
self.browser = webdriver.Firefox() | |
self.browser.implicitly_wait(30) | |
self.browser.stop = lambda x: WebDriverWait(self.browser, x).until(lambda x: False) | |
self.browser.get_body = lambda: self.browser.find_element_by_tag_name('body') | |
def tearDown(self): | |
super(MyLiveServerTestCase, self).tearDown() | |
self.browser.quit() | |
# self.display.stop() | |
def login_user(self): | |
# Rakesh opens his web browser, and goes to the website | |
self.browser.get(self.live_server_url + '/login/') | |
# He types in his username and passwords and hits return | |
username_field = self.browser.find_element_by_name('username') | |
username_field.send_keys('rakesh') | |
password_field = self.browser.find_element_by_name('password') | |
password_field.send_keys('ranjan') | |
password_field.send_keys(Keys.RETURN) | |
title = self.browser.find_element_by_tag_name('title') | |
print title.text | |
def login_staff(self): | |
# Rakesh opens his web browser, and goes to the website | |
self.browser.get(self.live_server_url + '/login/') | |
# He types in his username and passwords and hits return | |
username_field = self.browser.find_element_by_name('username') | |
username_field.send_keys('testadmin') | |
password_field = self.browser.find_element_by_name('password') | |
password_field.send_keys('testpass') | |
password_field.send_keys(Keys.RETURN) | |
class UserLiveServerTestCase(MyLiveServerTestCase): | |
def setUp(self): | |
super(UserLiveServerTestCase, self).setUp() | |
self.login_user() | |
class StaffLiveServerTestCase(MyLiveServerTestCase): | |
def setUp(self): | |
super(StaffLiveServerTestCase, self).setUp() | |
self.login_staff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment