Exemplo n.º 1
0
    def __init__(self, config):
        #BEGIN_CONSTRUCTOR
        config = Validation.validate_config(config)

        self.auth_url = config['auth-url']
        #END_CONSTRUCTOR
        pass
    def __init__(self, config):
        #BEGIN_CONSTRUCTOR
        # self.admin_users = string.split(os.environ.get('ADMIN_USERS', ''), ' ')
        self.admin_users = string.split(config['admin-users'], ' ')

        config = Validation.validate_config(config)

        self.db_config = config['mongo']

        self.auth_url = config['auth-url']

        #END_CONSTRUCTOR
        pass
    def test_model_no_token(self):
        auth_url = self.cfg['auth-url']
        admin_users = self.cfg['admin-users']
        token = self.ctx['token']
        username = self.ctx['user_id']
        config = Validation.validate_config(self.cfg)
        db_config = config['mongo']

        try:
            uis = UIServiceModel(auth_url, None, username, admin_users,
                                 db_config)
            uis.delete_alert('abc')
            self.assertTrue(False)
        except Exception as ex:
            self.assertTrue(True)

        try:
            uis = UIServiceModel(auth_url, token, 'not_an_admin', admin_users,
                                 db_config)
            uis.delete_alert('abc')
            self.assertTrue(False)
        except Exception as ex:
            self.assertTrue(True)