def setUp(self): # Call parent setUp super(UITests, self).setUp() # Log out util.logout(self.driver)
def tearDown(self): # Log out util.logout(self.driver) # Call parent tearDown super(UserSmokeTest, self).tearDown()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--username', type=str, required=True) parser.add_argument('--password', type=str, required=True) parser.add_argument('--host', type=str) parser.add_argument('--token', type=str) parser.add_argument('--custom_id', type=str) parser.add_argument('--file', type=str, required=True, help='send e-mail from file') parser.add_argument('--type', type=int, default=BILL_OF_LADING_ID, help='send e-mail from file') args = parser.parse_args() if args.host: host = args.host else: host = DEFAULT_HOST if args.custom_id: _custom_id = args.custom_id else: _custom_id = str(uuid.uuid4()) if not args.token: _token = login(host, args.username, args.password) else: _token = args.token upload(host, args.file, args.type, _token, _custom_id) if not args.token: logout(host, _token)
def test_create(self): """ Test if app creates new todo item """ todo1 = create(self, 'Write app tests') assert todo1['title'] == 'Write app tests' assert todo1['order'] == 1 assert not todo1['completed'] assert todo1['user'] == 'tsheasha' todo2 = create(self, 'Write automation tests', completed=True) assert todo2['title'] == 'Write automation tests' assert todo2['order'] == 2 assert todo2['completed'] assert todo2['user'] == 'tsheasha' logout(self) login(self, "nahla", "password") todo3 = create(self, 'Write automation tests', completed=True) assert todo3['title'] == 'Write automation tests' assert todo3['order'] == 3 assert todo3['completed'] assert todo3['user'] == 'nahla'
def test_add_contributor_log(self): """ test to make sure that add contributor log works correctly """ # As of 9 Sep 2013, log says "component"; expected "project" # Log out user_url = self.get_user_url() util.logout(self.driver) # Create second user and get his url second_user_data = util.create_user(self.driver) util.login( self.driver, second_user_data['username'], second_user_data['password'] ) project_url = util.create_project(self.driver) #add contributor self.add_contributor(self.user_data) #get log message_log = self.get_log() #assert the time self._assert_time(message_log.log_time) #assert the log self.assertEqual( message_log.log_text, u'{} added {} as contributor on node {}'.format( second_user_data['fullname'], self.user_data['fullname'], config.project_title, ) ) #check the user_url and project_url self.assertEqual( message_log.log_url[0], self.get_user_url() ) self.assertEqual( message_log.log_url[1], user_url ) self.assertEqual( message_log.log_url[2], project_url.strip('/') )
def test_logout(self): # Login util.login(self.driver, self.user_data['username'], self.user_data['password']) #logout util.logout(self.driver) # Check for alert alerts = util.get_alert_boxes(self.driver, 'You have successfully logged out.') self.assertEqual(len(alerts), 1)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--username', type=str, required=True) parser.add_argument('--password', type=str, required=True) parser.add_argument('--host', type=str) parser.add_argument('--custom_id', type=str, required=True) args = parser.parse_args() if args.host: host = args.host else: host = DEFAULT_HOST _token = login(host, args.username, args.password) query(host, args.custom_id, _token) logout(host, _token)
def test_logout(self): # Login util.login( self.driver, self.user_data['username'], self.user_data['password'] ) #logout util.logout(self.driver) # Check for alert alerts = util.get_alert_boxes(self.driver, 'You have successfully logged out.') self.assertEqual(len(alerts), 1) #self.assertTrue('/dashboard' in self.driver.current_url)
def test_delete_contributor_log(self): # As of 9 Sep 2013, the log says "component"; expected "project" # Log out user_url = self.get_user_url() util.logout(self.driver) # Create second user and get his url second_user_data = util.create_user(self.driver) util.login( self.driver, second_user_data['username'], second_user_data['password'] ) project_url = util.create_project(self.driver) #add contributor self.add_contributor(self.user_data) time.sleep(3) #remove contributor self.remove_contributor(self.user_data) time.sleep(3) #get log message_log = self.get_log() #assert the time self._assert_time(message_log.log_time) #assert the log self.assertEqual( message_log.log_text, u'{} removed {} as a contributor from project {}'.format( second_user_data["fullname"], self.user_data['fullname'], config.project_title ) ) #check the second user_url, first user_url and project_url self.assertEqual(message_log.log_url[0], self.get_user_url()) self.assertEqual(message_log.log_url[1], user_url) self.assertEqual(message_log.log_url[2]+"/", project_url)
def setUpClass(cls): # Start WebDriver cls.driver = webdriver.Firefox() # cls.driver.implicitly_wait(5) # Create user account and login cls.user_data = util.create_user(cls.driver) util.login(cls.driver, cls.user_data['username'], cls.user_data['password']) # Create test project and store URL cls.project_url = util.create_project(cls.driver) # Log out util.logout(cls.driver)
def setUpClass(cls): # Start WebDriver cls.driver = webdriver.Firefox() # cls.driver.implicitly_wait(5) # Create user account and login cls.user_data = util.create_user(cls.driver) util.login( cls.driver, cls.user_data['username'], cls.user_data['password'] ) # Create test project and store URL cls.project_url = util.create_project(cls.driver) # Log out util.logout(cls.driver)
def test_node_add_contributor_log(self): """ test to make sure that project log works correctly on adding contributor to a node """ # Log out user_url=self.get_user_url() util.logout(self.driver) # Create second user and get his url second_user_data = util.create_user(self.driver) util.login( self.driver, second_user_data['username'], second_user_data['password'] ) util.create_project(self.driver) util.create_node(self.driver) self.driver.find_element_by_css_selector("li span a").click() new_node_url=self.driver.current_url #add contributor self.add_contributor(self.user_data) #get log util.goto_project(self.driver) message_log = self.get_log() #assert the time self._assert_time(message_log.log_time) #assert the log self.assertEqual(message_log.log_text, second_user_data["fullname"] + " added " + self.user_data['fullname'] + " as contributor on node " + config.node_title) #check the second user_url, first user_url and node_url self.assertEqual(message_log.log_url[0], self.get_user_url()) self.assertEqual(message_log.log_url[1], user_url) self.assertEqual(message_log.log_url[2]+"/", new_node_url)
def test_node_add_contributor_log(self): """ test to make sure that project log works correctly on adding contributor to a node """ # Log out user_url = self.get_user_url() util.logout(self.driver) # Create second user and get his url second_user_data = util.create_user(self.driver) util.login(self.driver, second_user_data['username'], second_user_data['password']) util.create_project(self.driver) util.create_node(self.driver) self.driver.find_element_by_css_selector("li span a").click() new_node_url = self.driver.current_url #add contributor self.add_contributor(self.user_data) #get log util.goto_project(self.driver) message_log = self.get_log() #assert the time self._assert_time(message_log.log_time) #assert the log self.assertEqual( message_log.log_text, second_user_data["fullname"] + " added " + self.user_data['fullname'] + " as contributor on node " + config.node_title) #check the second user_url, first user_url and node_url self.assertEqual(message_log.log_url[0], self.get_user_url()) self.assertEqual(message_log.log_url[1], user_url) self.assertEqual(message_log.log_url[2] + "/", new_node_url)
def test_create(self): """ Test if API creates new todo item """ todo = {"title": 'Write API tests', "order": self.order, "user_id":1} todo1 = create(self, url='/api', inp=todo) assert todo1['title'] == 'Write API tests' assert todo1['order'] == 1 assert not todo1['completed'] assert todo1['user'] == 'tsheasha' todo = {"title": 'Write automation tests', "order": self.order, "user_id":1} todo2 = create(self, url='/api', inp=todo) assert todo2['title'] == 'Write automation tests' assert todo2['order'] == 2 assert not todo2['completed'] assert todo2['user'] == 'tsheasha' assert todo1['id'] != todo2['id'] logout(self) login(self, "nahla", "password") todo = {"title": 'Write automation tests', "order": self.order, "user_id":2} todo3 = create(self, url='/api', inp=todo) assert todo3['title'] == 'Write automation tests' assert todo3['order'] == 3 assert not todo3['completed'] assert todo3['user'] == 'nahla'
def logout(self, username): return util.logout(self.client, username)
contest = args.c.upper() else: contest = '' file = args.f lang_code = LANG_CODES[args.l] cookies = util.login(username, passwd) if not cookies: exit("Could not login") print "Successfully Logged in!" print "Submitting Your source code..." r = util.submit(cookies, pname, file, lang_code, contest) if not r: print "Could not submit the problem.Please check if problem name and/or contest name are correct" util.logout(cookies) exit() s_id = util.get_submission_id(r.text) if not s_id: print "There was some problem in retrieving your submission id.Please try again." util.logout(cookies) exit() print "Your submission id is %s" % s_id status = util.get_submission_status(s_id) if not status: print "Could not get submission status." print "Your submission status :" pprint(status) util.logout(cookies)
response = requests.get( url='https://api.investfly.com/stockmarket/quote?symbol=TSLA&market=US&' 'securityType=STOCK&realtime=true', headers=headers) tsla_price = json.loads(response.text)['lastPrice'] # current price # Execute trade if prices satisfy criterion if (tsla_price_1 - tsla_price_2) / tsla_price_2 <= -0.05 and \ 0 > (tsla_price_0 - tsla_price_1) / tsla_price_1 >= -0.02 and tsla_price - tsla_price_0 > 0: headers_copy = dict(headers) security = {'symbol': 'TSLA', 'securityType': 'STOCK', 'market': 'US'} trade_headers = { 'tradeType': 'BUY', 'orderType': 'MARKET_ORDER', 'quantity': '50', 'brokerType': 'INVESTFLY', 'security': security } trade_headers_json = json.dumps(trade_headers) portfolio_id = '1465449' response = requests.post( url='https://api.investfly.com/portfolio/Investfly/' + portfolio_id + '/trade?market=US', headers=headers, data=trade_headers_json) print(trade_headers) print(json.loads(response.text)) util.logout(client_id, client_token)
def logout(self, username): return util.logout(username)
def tearDown(self): util.logout(self.driver) # Close WebDriver self.driver.close()
def log_out(self): return util.logout(self.driver)
def logout(): util.logout() return redirect(url_for('index'))
def get(self): logout_url = util.logout() self.redirect(logout_url)