def login(self, username='******', password='******'): leap_session = self._test_account.leap_session user_auth = mock() user_auth.uuid = 'some_user_uuid' leap_session.user_auth = user_auth config = mock() config.leap_home = 'some_folder' leap_session.config = config leap_session.fresh_account = False self.leap_session = leap_session self.services = self._test_account.services self._set_leap_srp_auth(username, password, user_auth) when(LeapSessionFactory).create(username, password, user_auth).thenReturn(leap_session) when(leap_session).initial_sync().thenAnswer( lambda: defer.succeed(None)) when(pixelated.config.services).Services(ANY()).thenReturn( self.services) request = request_mock(path='/login', method="POST", body={ 'username': username, 'password': password }) return self._render(request, as_json=False)
def get(self, path, get_args='', as_json=True, from_request=None): request = request_mock(path) request.args = get_args if from_request: session = from_request.getSession() request.session = session return self._render(request, as_json)
def post(self, path, body='', headers=None, ajax=True, csrf='token', as_json=True, from_request=None): headers = headers or {'Content-Type': 'application/json'} request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf) if from_request: session = from_request.getSession() request.session = session return self._render(request, as_json)
def delete(self, path, body="", ajax=True, csrf='token'): request = request_mock(path=path, body=body, headers={'Content-Type': ['application/json']}, method="DELETE", ajax=ajax, csrf=csrf) return self._render(request)
def post(self, path, body='', headers=None, ajax=True, csrf='token'): headers = headers or {'Content-Type': 'application/json'} request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf) return self._render(request)
def login(self, username="******", password="******"): leap_session = mock(LeapSession) user_auth = mock() user_auth.uuid = "some_user_uuid" leap_session.user_auth = user_auth config = mock() config.leap_home = "some_folder" leap_session.config = config leap_session.fresh_account = False self._set_leap_srp_auth(username, password) when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None)) when(LeapSessionFactory).create(username, password).thenReturn(leap_session) when(pixelated.config.services).Services(ANY()).thenReturn(self._test_account.services) request = request_mock(path="/login", method="POST", body={"username": username, "password": password}) return self._render(request, as_json=False)
def login(self, username='******', password='******'): leap_session = self._test_account.leap_session user_auth = mock() user_auth.uuid = 'some_user_uuid' leap_session.user_auth = user_auth config = mock() config.leap_home = 'some_folder' leap_session.config = config leap_session.fresh_account = False self.leap_session = leap_session self.services = self._test_account.services self._set_leap_srp_auth(username, password, user_auth) when(LeapSessionFactory).create(username, password, user_auth).thenReturn(leap_session) when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None)) when(pixelated.config.services).Services(ANY()).thenReturn(self.services) request = request_mock(path='/login', method="POST", body={'username': username, 'password': password}) return self._render(request, as_json=False)
def post(self, path, body="", headers=None, ajax=True, csrf="token"): headers = headers or {"Content-Type": "application/json"} request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf) return self._render(request)
def get(self, path, get_args="", as_json=True, ajax=True, csrf="token"): request = request_mock(path, ajax=ajax, csrf=csrf) request.args = get_args return self._render(request, as_json)
def delete(self, path, body=""): request = request_mock(path=path, body=body, headers={"Content-Type": ["application/json"]}, method="DELETE") return self._render(request)
def put(self, path, body): request = request_mock(path=path, method="PUT", body=body, headers={"Content-Type": ["application/json"]}) return self._render(request)
def get(self, path, get_args="", as_json=True): request = request_mock(path) request.args = get_args return self._render(request, as_json)
def post(self, path, body='', headers=None): headers = headers or {'Content-Type': 'application/json'} request = request_mock(path=path, method="POST", body=body, headers=headers) return self._render(request)
def get(self, path, get_args='', as_json=True, ajax=True, csrf='token'): request = request_mock(path, ajax=ajax, csrf=csrf) request.args = get_args return self._render(request, as_json)
def put(self, path, body): request = request_mock(path=path, method="PUT", body=body, headers={'Content-Type': ['application/json']}) return self._render(request)
def get(self, path, get_args='', as_json=True): request = request_mock(path) request.args = get_args return self._render(request, as_json)
def post(self, path, body=''): request = request_mock(path=path, method="POST", body=body, headers={'Content-Type': ['application/json']}) return self._render(request)
def setUp(self): self.dummy_request = request_mock() self.controller = SyncInfoResource()
def put(self, path, body, ajax=True, csrf='token'): request = request_mock(path=path, method="PUT", body=body, headers={'Content-Type': ['application/json']}, ajax=ajax, csrf=csrf) return self._render(request)
def delete(self, path, body="", ajax=True, csrf="token"): request = request_mock( path=path, body=body, headers={"Content-Type": ["application/json"]}, method="DELETE", ajax=ajax, csrf=csrf ) return self._render(request)
def delete(self, path, body=""): request = request_mock(path=path, body=body, headers={'Content-Type': ['application/json']}, method="DELETE") return self._render(request)