class TestCli(unittest.TestCase): def setUp(self): self.cli = Cli() self.game = Mock() self.output = io.StringIO() self.input = io.StringIO("question") def tearDown(self): self.output.close() self.input.close() def test_run_game_not_running(self): self.game.get_start_message.return_value = "Welcome to the game!" self.game.is_running.return_value = False self.cli.run(self.game, self.output) self.assertEqual("\x1b[32m> Welcome to the game!\n\x1b[0m", self.output.getvalue()) def test_run_game_running(self): self.game.get_start_message.return_value = "Welcome to the game!" self.game.is_running.side_effect = [True, False] self.game.process_input.return_value = "answer" self.cli.run(self.game, self.output, self.input) self.assertEqual( "\x1b[32m> Welcome to the game!\n\x1b[0m> \x1b[32m> answer\n\x1b[0m", self.output.getvalue())
''' BLACK-AND-WHITE WinterSalmon Main ''' from gui.gui import Gui from cli.cli import Cli if __name__ == "__main__": # if pygame is not installed run game in commandline mode try: UI = Gui() except ImportError: UI = Cli() UI.init_screen() UI.game_screen() UI.credit_screen()
try: DEBUG = os.environ['DEBUG'] TOKEN = os.environ['AWS_TOKEN'] ACCESS_KEY = os.environ['AWS_ACCESS_KEY'] SECRET_KEY = os.environ['AWS_SECRET_KEY'] except: DEBUG = False TOKEN = None ACCESS_KEY = None SECRET_KEY = None if __name__ == "__main__": # Create cli object cli = Cli() # Create sd object sd = StackDeploy() # Ask for auth type and set credentials aws_auth = cli.ask_for_aws_auth_type() sd.auth_type = aws_auth['auth_type'] if aws_auth['auth_type'] == 'AWS Token': if DEBUG: sd.aws_token = TOKEN else: sd.aws_token = aws_auth['aws_token'] elif aws_auth['auth_type'] == 'AWS Key': if DEBUG: sd.aws_acces = ACCESS_KEY
''' BLACK-AND-WHITE WinterSalmon Main Cli ''' from cli.cli import Cli if __name__ == "__main__": CLI = Cli() CLI.init_screen() CLI.game_screen() CLI.credit_screen()
def setUp(self): self.cli = Cli() self.game = Mock() self.output = io.StringIO() self.input = io.StringIO("question")
def start_cli(args): cli = Cli() if args.list: cli.list() if args.login: cli.login(args.login, args.region, args.oneshot) if args.logout: cli.logout() if args.rotate_access_key: cli.rotate_access_key() if args.set_access_key: cli.set_access_key()
from cli.cli import Cli # Main method which executes the CLI if __name__ == "__main__": Cli()