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_missing_alert(self): driver.overview_go('All') assert driver.alerts() == [] driver.delete_form('CRF1') driver.overview_go('All') alerts = driver.alerts() assert len(alerts) == 2 assert len([alert for alert in alerts if 'not found' in alert]) == 1 assert len([alert for alert in alerts if '.xls not uploaded' in alert]) == 1 driver.upload_form(xlsforms['CRF1'])
def test_missing_alert(self): driver.overview_go('All') assert driver.alerts() == [] driver.delete_form('CRF1') driver.overview_go('All') alerts = driver.alerts() assert len(alerts) == 2 assert len([alert for alert in alerts if 'not found' in alert]) == 1 assert len([alert for alert in alerts if '.xls not uploaded' in alert]) == 1 driver.upload_form(xlsforms['CRF1'])
def test_login_fieldofficer(self): driver.login('fieldofficer', passwords['fieldofficer']) assert driver.title() == 'SAMPLE CONFIG' assert len(driver.menu_names()) == 1 assert not driver.single_sms_available() driver.logout() assert 'logged out' in driver.alerts()
def test_login_secretary(self): driver.login('secretary', passwords['secretary']) assert 'forms' not in driver.menu_names() assert 'admin' not in driver.menu_names() assert driver.single_sms_available() driver.logout() assert 'logged out' in driver.alerts()
def test_login_secretary(self): driver.login('secretary', passwords['secretary']) assert 'forms' not in driver.menu_names() assert 'admin' not in driver.menu_names() assert driver.single_sms_available() driver.logout() assert 'logged out' in driver.alerts()
def test_single(self): self.modify_config(False, '') numbers = driver.single_sms_go('80001') alerts = driver.alerts() assert len(alerts) == 1 and 'will not actually send' in alerts[0] assert numbers == ['255123456789', '255987654321'] alert = driver.single_sms_send('message', 1) assert 'sent message' in alert and numbers[1] in alert
def test_single(self): self.modify_config(False, '') numbers = driver.single_sms_go('80001') alerts = driver.alerts() assert len(alerts) == 1 and 'will not actually send' in alerts[0] assert numbers == ['255123456789', '255987654321'] alert = driver.single_sms_send('message', 1) assert 'sent message' in alert and numbers[1] in alert
def test_login_fieldofficer(self): driver.login('fieldofficer', passwords['fieldofficer']) assert driver.title() == 'SAMPLE CONFIG' assert 'forms' not in driver.menu_names() assert 'admin' not in driver.menu_names() assert not driver.single_sms_available() driver.logout() assert 'logged out' in driver.alerts()
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 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_login_admin(self): assert not driver.logged_in() driver.login('admin', passwords['admin']) assert driver.logged_in() assert driver.title() == 'SAMPLE CONFIG' items = driver.menu_names() assert 'forms' in items assert 'admin' in items assert 'help' in items driver.logout() assert 'logged out' in driver.alerts()
def test_login_admin(self): assert not driver.logged_in() driver.login('admin', passwords['admin']) assert driver.logged_in() assert driver.title() == 'SAMPLE CONFIG' items = driver.menu_names() assert 'forms' in items assert 'admin' in items assert 'help' in items driver.logout() assert 'logged out' in driver.alerts()
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 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_mass_sms(self): self.modify_config(False, '') driver.mass_sms_reset() assert not driver.has_mass_sms() template = 'glc={LRF1\\BLOOD_GLUCOSE}' template += ' weight={CRF2\\SIGNS_WEIGHT}' template += ' allergy={CRFX\\XRAY_ALLERGY}' self.modify_config(False, 'sms:DM', template) driver.mass_sms_reset() assert driver.has_mass_sms() driver.mass_sms_go() alerts = driver.alerts() assert len(alerts) == 1 and 'will not actually send' in alerts[0] assert driver.mass_sms_send() == 2 message = driver.mass_sms_messages()[0] assert re.match(r'glc=[\d.]+ weight=\(masked\) allergy=NULL', message)
def test_mass_sms(self): self.modify_config(False, '') driver.mass_sms_reset() assert not driver.has_mass_sms() template = 'glc={LRF1\\BLOOD_GLUCOSE}' template += ' weight={CRF2\\SIGNS_WEIGHT}' template += ' allergy={CRFX\\XRAY_ALLERGY}' self.modify_config(False, 'sms:DM', template) driver.mass_sms_reset() assert driver.has_mass_sms() driver.mass_sms_go() alerts = driver.alerts() assert len(alerts) == 1 and 'will not actually send' in alerts[0] assert driver.mass_sms_send() == 2 message = driver.mass_sms_messages()[0] assert re.match(r'glc=[\d.]+ weight=\(masked\) allergy=NULL', message)
def test_login_failed(self): t0 = time.time() driver.login('admin', 'admin') assert 'wrong password' in driver.alerts() assert time.time() - t0 > 2.
def test_login_failed(self): t0 = time.time() driver.login('admin', 'admin') assert 'wrong password' in driver.alerts() assert time.time() - t0 > 2.
def test_no_errors(self): ec = default_config() upload_config(ec) assert driver.alerts() == []