def test_mark_lost__unauthorized(self, mock_xsrf_token, mock_marklost): del mock_xsrf_token # unused. mock_marklost.side_effect = device_model.UnauthorizedError() with self.assertRaises(endpoints.UnauthorizedException): self.service.mark_lost( device_messages.DeviceRequest( urlkey=self.device.key.urlsafe()))
def test_resume_loan__unauthorized(self, mock_xsrf_token, mock_resume_loan): del mock_xsrf_token # unused. self.login_endpoints_user() mock_resume_loan.side_effect = device_model.UnauthorizedError() with self.assertRaises(endpoints.UnauthorizedException): self.service.resume_loan( device_message.DeviceRequest(urlkey=self.device.key.urlsafe()))
def test_mark_undamaged__unauthorized(self, mock_markundamaged): self.login_endpoints_user() with mock.patch.object(self.service, 'check_xsrf_token') as mock_xsrf: mock_markundamaged.side_effect = device_model.UnauthorizedError() with self.assertRaises(endpoints.UnauthorizedException): self.service.mark_undamaged( device_messages.DeviceRequest( urlkey=self.device.key.urlsafe())) assert mock_xsrf.call_count == 1
def test_mark_damaged__unauthorized(self, mock_xsrf, mock_markdamaged): del mock_xsrf # unusued. self.login_endpoints_user() mock_markdamaged.side_effect = device_model.UnauthorizedError() with self.assertRaises(endpoints.UnauthorizedException): self.service.mark_damaged( device_messages.DamagedRequest( device=device_messages.DeviceRequest( urlkey=self.device.key.urlsafe()), damaged_reason='Foo'))