Example #1
0
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()
Example #2
0
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()
Example #3
0
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)
Example #4
0
    def test_default_action_when_target_not_set(self, write_mock):
        self.expected = ""

        def assert_written(message):
            if message.strip() != "":
                self.expected = message

        write_mock.side_effect = assert_written

        wightApp = WightApp()
        ctrl = self.make_controller(AuthController,
                                    conf=self.fixture_for('test.conf'),
                                    app=wightApp)

        try:
            expect(ctrl.default()).to_be_false()
            assert False, "Should have called sys.exit(0)"
        except SystemExit:
            assert True

        expected = "You need to set the target to use wight. Use 'wight target-set <url of target>' to login."
        expect(self.expected).to_be_like(expected)
Example #5
0
 def setUp(self):
     super(TestWightApp, self).setUp()
     self.reset_backend()
     self.app = WightApp(argv=[], config_files=[])