def main(): defaults = backend.defaults('wight', 'log') defaults['log']['level'] = 'WARN' app = WightApp(config_defaults=defaults) app.register_controllers() bright_yellow = "%s%s" % (Fore.YELLOW, Style.BRIGHT) bright_magenta = "%s%s" % (Fore.MAGENTA, Style.BRIGHT) dim_red = "%s%s" % (Fore.RED, Style.DIM) dim_white = "%s%s" % (Fore.WHITE, Style.DIM) reset = "%s%s" % (Style.RESET_ALL, dim_white) try: app.setup() app.run() except UnauthenticatedError: print "\n%sYou need to be logged to use this command. Use '%swight login%s %s<user e-mail>%s%s' to login.%s\n" % ( dim_red, bright_yellow, reset, bright_magenta, reset, dim_red, reset ) except TargetNotSetError: print "\n%sYou need to set the target to use wight. Use '%swight target-set%s %s<url of target>%s%s' to login.%s\n" % ( dim_red, bright_yellow, reset, bright_magenta, reset, dim_red, reset ) finally: app.close()
def main(): defaults = backend.defaults('wight', 'log') defaults['log']['level'] = 'WARN' app = WightApp(config_defaults=defaults) app.register_controllers() bright_yellow = "%s%s" % (Fore.YELLOW, Style.BRIGHT) bright_magenta = "%s%s" % (Fore.MAGENTA, Style.BRIGHT) dim_red = "%s%s" % (Fore.RED, Style.DIM) dim_white = "%s%s" % (Fore.WHITE, Style.DIM) reset = "%s%s" % (Style.RESET_ALL, dim_white) try: app.setup() app.run() except UnauthenticatedError: print "\n%sYou need to be logged to use this command. Use '%swight login%s %s<user e-mail>%s%s' to login.%s\n" % ( dim_red, bright_yellow, reset, bright_magenta, reset, dim_red, reset) except TargetNotSetError: print "\n%sYou need to set the target to use wight. Use '%swight target-set%s %s<url of target>%s%s' to login.%s\n" % ( dim_red, bright_yellow, reset, bright_magenta, reset, dim_red, reset) finally: app.close()
class TestWightApp(TestCase): app_class = WightApp def setUp(self): super(TestWightApp, self).setUp() self.reset_backend() self.app = WightApp(argv=[], config_files=[]) def test_wight_app(self): self.app.setup() self.app.run() self.app.close() def test_has_proper_controllers(self): self.app.setup() self.app.register_controllers() expect(self.app.controllers).to_length(21) expect(self.app.controllers).to_include(TargetSetController) expect(self.app.controllers).to_include(TargetGetController) expect(self.app.controllers).to_include(AuthController) expect(self.app.controllers).to_include(CreateTeamController) expect(self.app.controllers).to_include(ShowTeamController) expect(self.app.controllers).to_include(UpdateTeamController) expect(self.app.controllers).to_include(DeleteTeamController) expect(self.app.controllers).to_include(ShowUserController) expect(self.app.controllers).to_include(TrackLoadTestController) expect(self.app.controllers).to_include(TeamAddUserController) expect(self.app.controllers).to_include(TeamRemoveUserController) expect(self.app.controllers).to_include(CreateProjectController) expect(self.app.controllers).to_include(UpdateProjectController) expect(self.app.controllers).to_include(DeleteProjectController) expect(self.app.controllers).to_include(ChangePasswordController) expect(self.app.controllers).to_include(ScheduleLoadTestController) expect(self.app.controllers).to_include(ListLoadTestController) expect(self.app.controllers).to_include(InstanceLoadTestController) expect(self.app.controllers).to_include(ShowResultController) expect(self.app.controllers).to_include(SetDefaultController) expect(self.app.controllers).to_include(GetDefaultController)