def setUp(self): self.processor = processor(requestsGenerator) self.manager = Mock() self.manager.name = "account" self.processor.manager = self.manager self.response = Response("", Request({}, {}, ""))
def setUp(self): self.processor = processor(requestsGenerator) self.manager = Mock() self.manager.name = "list" self.manager.manage.return_value = [] self.processor.manager = self.manager self.new_response = Response("", Request({"id": 1, "login": "******", "password": "******"}, {}, ""))
def setUp(self): self.processor = processor(requestsGenerator) self.manager = Mock() self.manager.name = "session" self.processor.manager = self.manager self.response = Response( "", Request({}, { "type": "session", "user_id": 1 }, ""))
def get_account(self, request): if request.account["type"] == "account" or request.account[ "type"] == "admin": taken_response = self.processors["account"].process( Response( "new", Request({"type": "internal"}, { "type": "account", "login": request.account["login"], "password": request.account["password"] }, "get"))) request.account = taken_response.result["objects"][0] elif request.account["type"] == "session": taken_response = self.processors["account"].process( Response( "new", Request({"type": "internal"}, { "type": "account", "id": request.account["user_id"] }, "get"))) request.account = taken_response.result["objects"][0] return request
def verify_account(self, response_account): if response_account["type"] == "anonymous": return True elif response_account["type"] == "account" or response_account[ "type"] == "admin": account_response = Response( "new", Request({"type": "internal"}, { "type": "account", "login": response_account["login"], "password": response_account["password"] }, "get")) accounts = self.processors["account"].process( account_response).result["objects"] if len(accounts) == 1: if response_account["type"] == "account": return True elif response_account["type"] == "admin": if accounts[0]["account_type"] == "admin": return True elif response_account["type"] == "session": session_response = Response( "new", Request({"type": "internal"}, { "type": "session", "user_id": response_account["user_id"] }, "get")) sessions = self.processors["session"].process( session_response).result["objects"] keys = [session["key"] for session in sessions] if response_account["key"] in keys: return True return False
def setUp(self): self.guard = guard() self.response = Response("new", Request({}, {}, ""))
def setUp(self): self.processor = processor() self.response = Response("", Request({}, {}, ""))
def test_response(self): response = Response("new", self.request) self.assertEqual("new", response.status) self.assertEqual(self.request, response.request) self.assertEqual({}, response.result)