Пример #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()
Пример #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!'
Пример #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()
Пример #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()
Пример #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')
Пример #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
Пример #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!'
Пример #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
Пример #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
Пример #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)
Пример #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!'
Пример #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)
Пример #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')
Пример #14
0
def test_flask_simple():
    app.config['TESTING'] = True
    client = app.test_client()
    result = client.get('/')
    assert b'Hello World' == result.data
Пример #15
0
 def setUp(self):
     self.app = app.test_client()
Пример #16
0
 def setUp(self):  #setup flask
     self.app = app.test_client()
     self.app.testing = True
     pass
Пример #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
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
Пример #19
0
def client():
    client = app.test_client()
    return client
Пример #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)
Пример #21
0
def client():
    return app.test_client()
Пример #22
0
 def setUp(self):
     # create a test client
     self.app = app.test_client()
     self.app.testing = True
Пример #23
0
 def setUp(self):
     app.testing = True
     self.client = app.test_client()
Пример #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)
Пример #25
0
 def setUp(self):
     self.app = app.test_client()
Пример #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")
Пример #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)
Пример #28
0
def test_hello():
    response = app.test_client().get('/')

    assert response.status_code == 200
    assert response.data == b'Hello, World!'
Пример #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