Example #1
0
 def test_add_config_force_arg(self, parse_config_variables):
     app = AppController(None, Settings())
     app.api = Mock()
     args = Mock()
     args.name = 'app/dep'
     args.force_add = False
     args.variables = ['foo=bar', '--force']
     app.addConfig(args)
     self.assertTrue(parse_config_variables.called)
     self.assertTrue(app.api.update_addon.called)
Example #2
0
 def test_add_config_force_arg(self, parse_config_variables):
     app = AppController(None, Settings())
     app.api = Mock()
     args = Mock()
     args.name = 'app/dep'
     args.force_add = False
     args.variables = ['foo=bar', '--force']
     app.addConfig(args)
     self.assertTrue(parse_config_variables.called)
     self.assertTrue(app.api.update_addon.called)
Example #3
0
    def test__restart_workers(self):
        app = AppController(None, Settings())
        app.api = Mock()
        app.api.read_workers.return_value = [{'wrk_id': 'wrk1'}]
        app.api.read_worker.return_value = {'wrk_id': 'wrk1', 'command': 'command', 'params': 'params', 'size': 8}

        app._restartWorkers('app', 'dep')

        self.assertTrue(app.api.delete_worker.called)
        self.assertTrue(app.api.create_worker.called)
Example #4
0
 def test_deploy_restart_workers_no_dep_name(self, time):
     app = AppController(None, Settings())
     app.api = Mock()
     app.api.read_deployment.return_value = {'state': 'deployed'}
     app._restartWorkers = Mock()
     args = Mock()
     args.name = 'app'
     args.memory = False
     app.deploy(args)
     self.assertTrue(app._restartWorkers.called)
     self.assertEqual(call('app', 'default'), app.api.read_deployment.call_args_list[0])
Example #5
0
 def test_restart_worker_with_all(self):
     app = AppController(None, Settings())
     app._restartWorker = Mock()
     app._restartWorkers = Mock()
     app.api = Mock()
     app.api.read_worker.return_value = {'wrk_id': 'wrk1', 'command': 'command', 'params': 'params', 'size': 'size'}
     args = Mock()
     args.name = 'app/dep'
     args.wrk_id = False
     args.all = True
     app.restartWorker(args)
     self.assertTrue(app._restartWorkers.called)
Example #6
0
 def test_restart_worker_gone_error(self):
     app = AppController(None, Settings())
     app._restartWorker = Mock()
     app._restartWorkers = Mock()
     app.api = Mock()
     app.api.read_worker.side_effect = GoneError
     args = Mock()
     args.name = 'app/dep'
     args.wrk_id = 'wrkgone'
     args.all = False
     self.assertRaises(InputErrorException, app.restartWorker, args)
     self.assertFalse(app._restartWorker.called)
     self.assertFalse(app._restartWorkers.called)
Example #7
0
    def test_add_config_duplicated_flag(self, parse_config_variables):
        app = AppController(None, Settings())
        app.api = Mock()
        args = Mock()
        args.name = 'app/dep'
        args.force_add = True
        args.variables = ['foo=bar', '-f']
        with self.assertRaises(InputErrorException) as df:
            app.addConfig(args)

        self.assertEqual('[ERROR] Please, specify a flag only once.',
                         str(df.exception))
        self.assertFalse(parse_config_variables.called)
        self.assertFalse(app.api.update_addon.called)
Example #8
0
    def test_add_config_no_variables_given(self, parse_config_variables):
        app = AppController(None, Settings())
        app.api = Mock()
        args = Mock()
        args.name = 'app/dep'
        args.force_add = False
        args.variables = None
        with self.assertRaises(InputErrorException) as nvg:
            app.addConfig(args)

        self.assertEqual('[ERROR] You must provide some variables.',
                         str(nvg.exception))
        self.assertFalse(parse_config_variables.called)
        self.assertFalse(app.api.update_addon.called)
Example #9
0
    def test_add_config_duplicated_flag(self, parse_config_variables):
        app = AppController(None, Settings())
        app.api = Mock()
        args = Mock()
        args.name = 'app/dep'
        args.force_add = True
        args.variables = ['foo=bar', '-f']
        with self.assertRaises(InputErrorException) as df:
            app.addConfig(args)

        self.assertEqual(
            '[ERROR] Please, specify a flag only once.',
            str(df.exception))
        self.assertFalse(parse_config_variables.called)
        self.assertFalse(app.api.update_addon.called)
Example #10
0
    def test_add_config_no_variables_given(self, parse_config_variables):
        app = AppController(None, Settings())
        app.api = Mock()
        args = Mock()
        args.name = 'app/dep'
        args.force_add = False
        args.variables = None
        with self.assertRaises(InputErrorException) as nvg:
            app.addConfig(args)

        self.assertEqual(
            '[ERROR] You must provide some variables.',
            str(nvg.exception))
        self.assertFalse(parse_config_variables.called)
        self.assertFalse(app.api.update_addon.called)
Example #11
0
 def test__restart_worker(self):
     app = AppController(None, Settings())
     app.api = Mock()
     app._restartWorker('app_name', 'deployment_name', 'wrk_id', 'command', 'params', 'size')
     self.assertTrue(app.api.delete_worker.called)
     self.assertTrue(app.api.create_worker.called)