Ejemplo n.º 1
0
def make_shell():
    """Interactive Flask Shell"""
    from flask import request
    from hello import init_db as initdb
    app = make_app()
    http = app.test_client()
    reqctx = app.test_request_context
    return locals()
Ejemplo n.º 2
0
def test_app():
    # get main page
    response = app.test_client().get('/')

# test if status code 200 is returned
    assert response.status_code == 200
    # test if we get "Hello World!"
    assert response.data == b'Hello, World!'
Ejemplo n.º 3
0
def make_shell():
    """Interactive Flask Shell"""
    from flask import request
    from hello import init_db as initdb
    app = make_app()
    http = app.test_client()
    reqctx = app.test_request_context
    return locals()
Ejemplo n.º 4
0
 def setUp(self):
     app.config.update(
         TESTING=True,
         WTF_CSRF_ENABLED=False,
         SQLALCHEMY_DATABASE_URI='sqlite:///:memory:'
     )
     db.create_all()
     self.client = app.test_client()
     self.runner = app.test_cli_runner()
Ejemplo n.º 5
0
 def test_empty_username_password(self):
     print("test_empty_username_password")
     """when param loss some value,then return status code=65535 message]"""
     response = app.test_client().post('/addrec', data={})
     print("response",response)
     json_data = response.data
     print(json_data)
     json_dict = json.loads(json_data)
     self.assertEqual(json_dict['code'], 65536, 'data erro')
Ejemplo n.º 6
0
def test_storage(up, down):
    with app.test_client() as client, requests_mock.Mocker() as mocker:
        mocker.post(E2EMONITORING_URL, text='resp')
        assert len(storage) == 0
        client.post('/add', query_string=up)
        client.post('/add', query_string=down)
        client.post('/add', query_string=up)
        assert len(storage) == 3
        client.get('/flush/2')
        assert len(storage) == 2
Ejemplo n.º 7
0
def test_hello():
    """ Path root returns flask-example app and 'Hello, World' """
    response = app.test_client().get('/')

    assert response.status_code == 200
    assert response.data == b'Hello, World!'
Ejemplo n.º 8
0
def test_home():
    tester = app.test_client()
    response = tester.get('/', content_type='html/text')
    assert response.status_code == 200
    assert b'Hello World!' in response.data
Ejemplo n.º 9
0
def test_other():
    tester = app.test_client()
    response = tester.get('a', content_type='html/text')
    assert response.status_code == 404
    assert b'does not exist' in response.data
Ejemplo n.º 10
0
 def test_pages(self):
     tester = app.test_client(self)
     pages = ['/', 'about', 'register', 'login']
     for page in pages:
         response = tester.get(page, content_type='html/text')
         self.assertEqual(response.status_code, 200)
Ejemplo n.º 11
0
def test_hello():  # this merely is to validate the test environment
    response = app.test_client().get('/')
    assert response.status_code == 200
    assert response.data == b'Hello, World!'
Ejemplo n.º 12
0
 def test_post(self):
     self.test_app = app.test_client()
     response = self.test_app.get('/', content_type='html/text')
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 13
0
 def test_home(self):
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, b'Hello World')
Ejemplo n.º 14
0
def test_flask_simple():
    app.config['TESTING'] = True
    client = app.test_client()
    result = client.get('/')
    assert b'Hello World' == result.data
Ejemplo n.º 15
0
 def setUp(self):
     self.app = app.test_client()
Ejemplo n.º 16
0
 def setUp(self):  #setup flask
     self.app = app.test_client()
     self.app.testing = True
     pass
Ejemplo n.º 17
0
from hello import app
import json

testapp = app.test_client()


def test_index():
    response = testapp.get('/')
    assert response.status_code == 200
    assert b'Bienvenido seas.' in response.data


def test_ajax():
    response = testapp.post('/api/visitors',
                            data=json.dumps({'name': "Jose"}),
                            content_type='application/json')
    assert response.status_code == 200
    assert b'Jose' in response.data
Ejemplo n.º 18
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
Ejemplo n.º 19
0
def client():
    client = app.test_client()
    return client
Ejemplo n.º 20
0
    def test_post(self):

        self.test_app = app.test_client()

        response = self.test_app.get('/', content_type='html/text')
        self.assertEqual(response.status_code, 200)
Ejemplo n.º 21
0
def client():
    return app.test_client()
Ejemplo n.º 22
0
 def setUp(self):
     # create a test client
     self.app = app.test_client()
     self.app.testing = True
Ejemplo n.º 23
0
 def setUp(self):
     app.testing = True
     self.client = app.test_client()
Ejemplo n.º 24
0
 def test_other(self):
     tester = app.test_client(self)
     response = tester.get('a', content_type='html/text')
     self.assertEqual(response.status_code, 404)
     self.assertTrue(b'does not exist' in response.data)
Ejemplo n.º 25
0
 def setUp(self):
     self.app = app.test_client()
Ejemplo n.º 26
0
from hello import app
with app.test_client() as c:
    response = c.get('/')
    assert response.data == b'Hello World!'
    assert response.status_code == 200
    print("Test Passed")
Ejemplo n.º 27
0
 def test_other_page(self):
     tester = app.test_client(self)
     response = tester.get('test', content_type='html/text')
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 28
0
def test_hello():
    response = app.test_client().get('/')

    assert response.status_code == 200
    assert response.data == b'Hello, World!'
Ejemplo n.º 29
0
def test_response():
    """Start with a blank database."""
    client = app.test_client()
    rv = client.get('/')
    assert b'Hello from Kubernetes!' in rv.data