def modify_config(self): ''' changes config from demo/ and uploads to server :param report_mdays: config.xls cron.report_mdays setting :param template: will set template_DM to this template and activate sending of this template via cron ''' ec = default_config() upload_config(ec)
def test_all_sheets(self): ec = default_config() del ec.sheets['colors'] upload_config(ec) alerts = driver.alerts() error_msg = 'expected to find sheet' assert sum([error_msg in alert for alert in driver.alerts()]) > 0
def test_unknown_plugin(self): ec = default_config() ec.sheets['xxx'] = [['key', 'value']] upload_config(ec) alerts = driver.alerts() error_msg = 'unknown sheet' assert sum([error_msg in alert for alert in driver.alerts()]) > 0
def test_no_password(self): ec = default_config() ec.set_rows('users', 'name', 'secretary', 'password', '') upload_config(ec) alerts = driver.alerts() assert sum(['empty password' in alert for alert in driver.alerts()]) > 0 ec = ExcelConfig(driver.download_config()) rows = ec.get_rows('users', 'name', 'secretary') assert len(rows) == 1 and rows[0]['password'] != ''
def test_add(self): ec = default_config() ec.add_row('doughnut', {'key': 'colony_count_2', 'value':'LRF1\\SPUTUM_COLONY_COUNT negative'}) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 0 assert len(driver.els_xpath('//canvas')) == 7 ec = default_config() upload_config(ec)
def modify_config(self, production, more=None, template=None): ''' changes config from demo/ and uploads to server :param production: whether to set sms 'production' mode :param more: what to write in 'more' cell in sms demonstration entry :param template: change content of template_DM ''' ec = default_config() ec.set_value('sms', 'mode', production and 'production' or 'test') if more is not None: ec.set_rows('colors', 'comments', 'send sms', 'more', more) if template is not None: ec.set_value('sms', 'template_DM', template) upload_config(ec)
def test_create_user(self): driver.login('admin', passwords['admin']) ec = default_config() userdict = dict(name='blah', password='******', rights='overview') ec.add_row('users', userdict) upload_config(ec) driver.logout() assert not driver.logged_in() driver.login('blah', 'blah123') assert driver.logged_in() driver.logout()
def test_add(self): ec = default_config() ec.add_row('doughnut', { 'key': 'colony_count_2', 'value': 'LRF1\\SPUTUM_COLONY_COUNT negative' }) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 0 assert len(driver.els_xpath('//canvas')) == 7 ec = default_config() upload_config(ec)
def modify_config(self, report_mdays=None, template=None): ''' changes config from demo/ and uploads to server :param report_mdays: config.xls cron.report_mdays setting :param template: will set template_DM to this template and activate sending of this template via cron ''' ec = default_config() if report_mdays is not None: ec.set_value('cron', 'report_mdays', report_mdays) if template is None: ec.set_value('sms', 'mode', 'test') ec.set_value('sms', 'template_DM', '') ec.set_rows('colors', 'list', 'CRF1 submitted more than one week ago', 'more', '') else: ec.set_value('sms', 'mode', 'production') ec.set_value('sms', 'template_DM', template) ec.set_rows('colors', 'list', 'CRF1 submitted more than one week ago', 'more', 'sms:DM!') upload_config(ec)
def test_config(self): ec = default_config() ec.add_row('doughnut', {'key': 'empty', 'value':''}) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 1 assert 'expected' in alerts[0] assert len(driver.els_xpath('//canvas')) == 6 ec = default_config() upload_config(ec) ec.add_row('doughnut', {'key': 'unknown', 'value':'FORMX\\FIELDX value1'}) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 1 assert 'unknown' in alerts[0] assert len(driver.els_xpath('//canvas')) == 6 ec = default_config() upload_config(ec)
def test_config(self): ec = default_config() ec.add_row('doughnut', {'key': 'empty', 'value': ''}) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 1 assert 'expected' in alerts[0] assert len(driver.els_xpath('//canvas')) == 6 ec = default_config() upload_config(ec) ec.add_row('doughnut', { 'key': 'unknown', 'value': 'FORMX\\FIELDX value1' }) upload_config(ec) driver.menu_go('doughnut') alerts = driver.alerts() assert len(alerts) == 1 assert 'unknown' in alerts[0] assert len(driver.els_xpath('//canvas')) == 6 ec = default_config() upload_config(ec)
print('check instance name...') title = instance.driver.get_title() if title is None: error = instance.driver.get_error() fail('%s : %s' % (config.planner_url, error)) try: print('login...') instance.driver.login('admin', instance.passwords['admin']) if not instance.driver.logged_in(): raise Exception('failed to log in') except Exception as e: fail('could not log in as admin : ' + str(e), True) try: print('upload config...') instance.upload_config(instance.default_config()) except Exception as e: fail('could not upload default config : ' + str(e), True) try: print('initialize forms...') instance.init_forms() except Exception as e: fail('could not init forms : ' + str(e), True) missing = instance.driver.form_missing() if missing: fail('the following form(s) could not be found in the database : ' + ','.join(missing)) instance.driver.logout()
def test_no_errors(self): ec = default_config() upload_config(ec) assert driver.alerts() == []