async def test_server_channel(self): app = self.application() client = test.TestClient(app) request = await client.get('/') self.assertEqual(request.response.status_code, 404) self.assertTrue(app.channels) self.assertTrue('server' in app.channels)
async def test_get_html(self): app = self.application() client = test.TestClient(app) request = await client.get('/contact') bs = self.bs(request.response, 200) form = bs.find('lux-form') self.assertTrue(form)
async def test_post_one_email_form_valid(self): app = self.application() client = test.TestClient(app) data = dict(name='Pinco Pallino', email='*****@*****.**', body='Hi this is a test') request = await client.post('/contact', json=data) data = self.json(request.response, 200) self.assertEqual(data['message'], "Your message was sent! Thank You for your interest") self.assertEqual(len(app.email_backend.sent), 2)
async def test_reload(self): app = self.application() client = test.TestClient(app) await client.get('/') # reload the app clear_local = app.callable.clear_local future = asyncio.Future() def fire(): clear_local() future.set_result(None) app.callable.clear_local = fire await app.reload() await future
def test_is_secure(self): app = self.application( SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https')) client = test.TestClient(app) request, _ = client.request_start_response() self.assertFalse(request.is_secure)
def test_logger(self): app = self.application() client = test.TestClient(app) request, _ = client.request_start_response() self.assertEqual(app.logger, request.logger)
def test_is_secure_improperly_configured(self): app = self.application( SECURE_PROXY_SSL_HEADER='HTTP_X_FORWARDED_PROTO') client = test.TestClient(app) request, _ = client.request_start_response() self.assertRaises(ImproperlyConfigured, lambda: request.is_secure)
def test_is_secure(self): app = self.application() client = test.TestClient(app) request, _ = client.request_start_response('get', '/') self.assertFalse(request.is_secure)
async def test_command_error(self): app = self.application(MASTER_APPLICATION_ID=None) client = test.TestClient(app) await self.wait.assertRaises(CommandError, client.run_command, 'admin_app')
async def test_post_one_email_form_invalid(self): app = self.application() client = test.TestClient(app) data = dict(name='Pinco Pallino', email='*****@*****.**') request = await client.post('/contact', json=data) self.assertValidationError(request.response, 'body')