def create_event(): """ Create event """ with allure.step('Create event'): db = Connection() db.create_event() loger = PyLogging(__name__) loger.info("Create Event")
def delete_event(): """ Delete event """ yield with allure.step('Create event'): db = Connection() db.delete_event_with_name("Test Event") loger(__name__, 'info', 'Delete Event')
def delete_event(): """ Delete event """ yield with allure.step('Create event'): db = Connection() db.delete_event_with_name("Test Event") loger = PyLogging(__name__) loger.info("Delete event")
def create_category(): """ Create Category """ with allure.step('Create category {}'.format( CATEGORIESPAGE['category_old'])): db = Connection() db.create_category_with_name(CATEGORIESPAGE['category_old']) msg = "Create Category {}".format(CATEGORIESPAGE['category_old']) loger('Category', 'info', msg)
def test_registration(app): with allure.step("fill register form"): app.auth.fill_register_data(info['email_for_register'], info['password_for_register']) app.auth.send_escape() with allure.step("Confirm a user"): db = Connection() db.confirm_useremail_on_register(info['email_for_register']) with allure.step("fill login form"): app.auth.fill_login_data(info['email_for_register'], info['password_for_register']) with allure.step("Verify successfully login"): assert app.base.get_element_text(locator.NAME_USER) == info['username']
def delete_category(): """ Delete Category """ yield with allure.step('Delete category {}'.format( CATEGORIESPAGE['category_new'])): db = Connection() db.delete_category_with_name(CATEGORIESPAGE['category_new']) msg = "Delete Category {}".format(CATEGORIESPAGE['category_new']) loger('Category', 'info', msg)
def test_registration(app): with allure.step("fill register form"): app.auth.fill_register_data(info['email_for_register'], info['password_for_register']) app.auth.send_escape() with allure.step("Confirm a user"): db = Connection() db.confirm_useremail_on_register(info['email_for_register']) with allure.step("fill login form"): app.auth.fill_login_data(info['email_for_register'], info['password_for_register']) with allure.step("Verify successfully login"): assert app.base.check_if_element_exists(locator.PROFILE)
def create_engine(): global conn conn = Connection.get_connection() global cur if cur is None: cur = conn.cursor() conn.autocommit(1)
def __update(self, sql, add): c = Connection(self.config) if not self.inactive: sql += " where Active = 1" if self.mode == Mode.NEWEVENTS: if not self.inactive: sql += ' AND (LastUpdated < dateadd(day, -3, getdate()) or LastUpdated IS NULL)' else: sql += ' WHERE (LastUpdated < dateadd(day, -3, getdate()) or LastUpdated IS NULL)' data = c.execute(sql) for row in data: if add: if row['Parkrun'] not in self.__parkruns: self.logger.debug('Adding event {}'.format(row['Parkrun'])) self.__parkruns[row['Parkrun']] = { 'Name': row['Parkrun'], 'URL': row['URL'], 'EventURL': row['URL'].split('/')[3], 'lastEvent': row['LastEventNumber'], 'EventHistoryURL': row['EventHistoryURL'], 'EventNumberURL': row['EventNumberURL'], 'LatestResultsURL': row['LatestResultsURL'] } else: if row['Parkrun'] in self.__parkruns: self.logger.debug('Removing event {}'.format( row['Parkrun'])) del self.__parkruns[row['Parkrun']] data = c.execute("SELECT * FROM getParkrunCancellationsThisWeek") if self.mode == Mode.NEWEVENTS: for row in data: if row['Parkrun'] in self.__parkruns: self.logger.debug('Removing cancelled event {}'.format( row['Parkrun'])) del self.__parkruns[row['Parkrun']]
def delete_registered_user(): """ Delete user """ yield with allure.step('Delete registered user'): db = Connection() db.delete_user_with_email("*****@*****.**") loger(__name__, 'info', 'Delete User') db.close()
def delete_registered_user(): """ Delete user """ yield with allure.step('Delete registered user'): db = Connection() db.delete_user_with_email("*****@*****.**") loger = PyLogging(__name__) loger.info("Deleting user") db.close()
def setUpClass(cls): cls.header_user = Header().get_header_auth_user() cls.header_admin = Header().get_header_auth_admin() cls.create_mes = Connection().send_message()
def tearDownClass(cls): cls.del_mes = Connection().delete_mes_with_text()
def connect_bd(): con = Connection(DB_HOST, DB_SERVICE, DB_USER, DB_PASSWORD) con.connect() return con
def connect_bd(): con = Connection(DATABASE["DB_HOST"], DATABASE["DB_SERVICE"], DATABASE["DB_USER"], DATABASE["DB_PASSWORD"]) con.connect() return con
return data if __name__ == '__main__': loggingQueue = multiprocessing.Queue() listener = LogListener(loggingQueue) listener.start() config = sender_config config['handlers']['queue']['queue'] = loggingQueue logging.config.dictConfig(config) logger = logging.getLogger('checkhistory') c = Connection(config) parser = argparse.ArgumentParser() parser.add_argument( '--limit', type=int, default=40, help= 'Specify number of events and athlete needs to have completed to be selected.' ) parser.add_argument( '--delay', type=int, default=5, help='Wait n seconds before processing the next athlete')
def tearDownClass(cls): cls.conn = Connection() cls.conn.delete_user_with_email("*****@*****.**") cls.conn.close()
def __del__(self): Connection.close_connection()
def setUpClass(cls): cls.header = Header().get_header_auth_admin() cls.conn = Connection()
def delete_user_and_close_conn(): yield conn = Connection() conn.delete_user_with_email("*****@*****.**") conn.close()
def get_conn(): conn = Connection() return conn
def fixture_category_api(): conn = Connection() conn.create_category_with_name("category to be deleted") yield conn = Connection() conn.delete_category_with_name("new") conn.delete_category_with_name("category to be deleted") conn.edit_category_with_name("MountNew", "Mount") conn.close()
def fixture_chat_api(): conn = Connection() conn.send_message() yield conn.delete_mes_with_text() conn.close()
def setUpClass(cls): cls.header = Header().get_header_auth_admin() cls.conn = Connection() cls.conn.create_category_with_name("category to be deleted")
def run(self): c = Connection(self.config) logging.config.dictConfig(self.config) self.logger = logging.getLogger(__name__) self.logger.info('Process {} Running'.format(self.id)) self.msgQ.put(Message('Process', self.id, 'Running')) while True: parkrun = self.inQ.get() self.logger.debug(parkrun) if parkrun is None: self.logger.info('Process {} Exiting'.format(self.id)) self.msgQ.put(Message('Process', self.id, 'Exiting')) break self.logger.debug('Process {} got record {}'.format( self.id, parkrun['EventURL'])) if parkrun['lastEvent'] is None: parkrun['lastEvent'] = 0 if self.mode == Mode.CHECKURLS: if self.getURL(parkrun['URL']) is not None: c.updateParkrunURL(parkrun['Name'], True, True) self.msgQ.put( Message('Process', self.id, 'Verified ' + parkrun['Name'] + ' valid')) else: c.updateParkrunURL(parkrun['Name'], True, False) self.msgQ.put( Message( 'Error', self.id, 'Could not verify ' + parkrun['Name'] + ' as valid')) if self.mode == Mode.NEWEVENTS: self.logger.info( 'Process {} checking for new results for {}'.format( self.id, parkrun['EventURL'])) self.msgQ.put( Message('Process', self.id, 'Checking for new results for ' + parkrun['Name'])) parkrun['EventNumber'], parkrun[ 'EventDate'], data = self.getLatestEvent( parkrun['URL'] + parkrun['LatestResultsURL']) if data is not None: self.logger.debug( 'Event {} got {} events in history'.format( parkrun['EventURL'], len(data))) parkrun['Runners'] = len(data) # Add the event if it's a new event # Check the event has the correct number of runners if not c.checkParkrunEvent(parkrun): self.logger.info( 'Parkrun {} event {}: runners did not match - reimporting.' .format(parkrun['Name'], parkrun['EventNumber'])) #if not, delete the old event record and re-import the data self.msgQ.put( Message( 'Process', self.id, 'Updating ' + parkrun['Name'] + ' event ' + xstr(parkrun['EventNumber']))) eventID = c.replaceParkrunEvent(parkrun) self.logger.debug( 'getLastEvent found {} runners'.format(len(data))) for row in data: row['EventID'] = eventID c.addParkrunEventPosition(row) sleep(self.delay) if self.mode == Mode.NORMAL: data = self.getEventHistory(parkrun['URL'] + parkrun['EventHistoryURL']) if data is not None: self.logger.debug( 'Event {} got {} events in history'.format( parkrun['URL'], len(data))) for row in data: row['Name'] = parkrun['Name'] row['EventURL'] = parkrun['EventURL'] # Add the event if it's a new event self.msgQ.put( Message( 'Process', self.id, 'Checking ' + row['Name'] + ' event ' + xstr(row['EventNumber']))) self.logger.debug(row) self.logger.debug( 'Process {} Checking {} event {}'.format( self.id, row['EventURL'], xstr(row['EventNumber']))) # Check the event has the correct number of runners if not c.checkParkrunEvent(row): #if not, delete the old event record and re-import the data self.logger.info( 'Parkrun {} event {}: runners did not match - reimporting.' .format(parkrun['EventURL'], row['EventNumber'])) self.msgQ.put( Message( 'Process', self.id, 'Updating ' + row['Name'] + ' event ' + xstr(row['EventNumber']))) eventID = c.replaceParkrunEvent(row) eData = self.getEvent( parkrun['URL'] + parkrun['EventNumberURL'], row['EventNumber']) if eData is not None: self.logger.debug( 'getEvent found {} runners'.format( len(eData))) for eRow in eData: eRow['EventID'] = eventID c.addParkrunEventPosition(eRow) sleep(self.delay) else: self.logger.debug('getEvent found no runners') else: self.logger.warning( 'Parkrun {} returns no history page.'.format( parkrun['Name'])) c.execute( "update p set p.LastUpdated = e.LastEvent from parkruns as p inner join (select ParkrunID, max(EventDate) as LastEvent from events group by ParkrunID) as e on p.ParkrunID = e.ParkrunID" ) self.logger.debug('Sleeping for {} seconds'.format(self.delay)) sleep(self.delay) c.close()
def tearDownClass(cls): cls.conn = Connection() cls.conn.delete_category_with_name("new") cls.conn.delete_category_with_name("category to be deleted") cls.conn.edit_category_with_name("MountNew", "Mount") cls.conn.close()