def test_everything_loud(pformat, stderr): """Eat up the stderr stuff.""" pformat.return_value = "item" preflyt.check(CHECKERS, loud=True) stderr.assert_has_calls([ call("Preflyt Checklist\n=================\n"), call(" item\n") ])
def test_load_called(load_checkers): """Verify the load method is called""" checkers = preflyt.CHECKERS preflyt.CHECKERS = {} try: preflyt.check([]) load_checkers.assert_called_once_with() finally: preflyt.CHECKERS = checkers
def test_everything_failure(): """Test the check method.""" good, results = check(BAD_CHECKERS) ok_(not good, results) eq_(len(results), 1) for field_name in ('check', 'success', 'message'): ok_(field_name in results[0])
def test_check_failure(): """Test the check method.""" good, results = preflyt.check(BAD_CHECKERS) ok_(not good, results) eq_(len(results), 1) for field_name in ('check', 'success', 'message'): ok_(field_name in results[0])
def test_check_success(): """Test the check method.""" good, results = preflyt.check(CHECKERS) ok_(good, results) eq_(len(results), 1) for field_name in ('check', 'success', 'message'): ok_(field_name in results[0])
def test_everything(): """Test the check method.""" good, results = check(CHECKERS) ok_(good, results) eq_(len(results), 1) for field_name in ('check', 'success', 'message'): ok_(field_name in results[0])
def main(): load_dotenv() ok, _ = preflyt.check( [ {"checker": "env", "name": "MATRIX_USERNAME"}, {"checker": "env", "name": "MATRIX_PASS"}, {"checker": "env", "name": "MATRIX_SERVER"}, {"checker": "env", "name": "TS_HOST"}, {"checker": "env", "name": "TS_USERNAME"}, {"checker": "env", "name": "TS_PASSWORD"}, {"checker": "env", "name": "EVENT_ROOMS"}, ] ) if not ok: print("Not all required config options are specified") return user, password, server = ( os.getenv("MATRIX_USERNAME"), os.getenv("MATRIX_PASS"), os.getenv("MATRIX_SERVER"), ) ts_user, ts_password, ts_server = ( os.getenv("TS_USERNAME"), os.getenv("TS_PASSWORD"), os.getenv("TS_HOST"), ) event_rooms = os.getenv("EVENT_ROOMS").split(",") creds = botlib.Creds(server, user, password) bot = botlib.Bot(creds) ts3conn = TS3Connection(ts_server) ts3conn.login(ts_user, ts_password) ts3conn.use(1) new_online_clients = show_online_clients_wrapper(bot, ts3conn) bot.add_message_listener(new_online_clients) poke_client = poke_client_wrapper(bot, ts3conn) bot.add_message_listener(poke_client) event_handler = create_event_handler(bot, event_rooms, ts3conn) ts3conn.register_for_server_events(event_handler, False) ts3conn.register_for_channel_events(0, event_handler, False) ts3conn.register_for_unknown_events(event_handler, False) ts3conn.start_keepalive_loop() bot.run()
def test_missing_checker(): preflyt.check([{"checker": "noop"}])