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 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 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 fixture_chat_api(): conn = Connection() conn.send_message() yield conn.delete_mes_with_text() conn.close()
def delete_user_and_close_conn(): yield conn = Connection() conn.delete_user_with_email("*****@*****.**") conn.close()