introduce blueprints and unit tests
This commit is contained in:
parent
f5d8f1d6e3
commit
f7ede63681
7 changed files with 121 additions and 35 deletions
20
tests/test_basic.py
Normal file
20
tests/test_basic.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import unittest
|
||||
from flask import current_app
|
||||
from app import create_app
|
||||
|
||||
|
||||
class BasicsTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.app = create_app('testing')
|
||||
self.app_context = self.app.app_context()
|
||||
self.app_context.push()
|
||||
|
||||
def tearDown(self):
|
||||
self.app_context.pop()
|
||||
|
||||
def test_app_exists(self):
|
||||
self.assertFalse(current_app is None)
|
||||
|
||||
def test_app_is_testing(self):
|
||||
self.assertTrue(current_app.config['TESTING'])
|
19
tests/test_index.py
Normal file
19
tests/test_index.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import unittest
|
||||
from app import create_app
|
||||
|
||||
|
||||
class BasicsTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.app = create_app('testing')
|
||||
self.app_context = self.app.app_context()
|
||||
self.app_context.push()
|
||||
|
||||
def tearDown(self):
|
||||
self.app_context.pop()
|
||||
|
||||
def test_index(self):
|
||||
with self.app.test_client() as test_client:
|
||||
response = test_client.get('/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn(b'<h1>RGB controller</h1>', response.data)
|
Loading…
Add table
Add a link
Reference in a new issue