Example #1
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF-CSRF_DATABASE_URI'] = False
     app.config['SQLALCHEMY_DATABASE_RUI'] = 'sqlite:///' + os.path.join(
         basedir, 'test.db')
     self.app = app.test_client()
     db.create_all()
Example #2
0
 def test_login_incorrect(self):
     tester = app.test_client(self)
     response = tester.post('/login',
                            data=dict(username='******',
                                      password='******'),
                            follow_redirects=True)
     self.assertTrue(b'Bad username' in response.data)
Example #3
0
 def test_logout(self):
     tester = app.test_client(self)
     response = tester.post('/login',
                            data=dict(username='******', password='******'),
                            follow_redirects=True)
     response = tester.get('/logout', follow_redirects=True)
     self.assertTrue(b'logout succeded' in response.data)
Example #4
0
 def setUp(self):
     """ Setup   A blank database for testing """
     app.config.from_object('config.TestingConfig')
     self.client = MongoClient(app.config["MONGO_URI"])
     self.db = self.client[app.config['DB']]
     self.collection = self.db[app.config['COLLECTION']]
     self.collection.insert_one(({"test": "test"}))
     self.app = app.test_client()
Example #5
0
 def setUp(self):
     """Set up a blank temp database before each test"""
     basedir = os.path.abspath(os.path.dirname(__file__))
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
         os.path.join(basedir, TEST_DB)
     self.app = app.test_client()
     db.create_all()
Example #6
0
def before_feature(context, feature):
    context.db, app.config['DATABASE'] = tempfile.mkstemp()
    app.testing = True

    context.client = app.test_client()

    with app.app_context():
        init_db()
Example #7
0
def test_hola_falabella():
    """
    Se debe obtener un Hola Falabella! al acceder a
    /hello
    """
    with app.test_client() as test_client:
        response = test_client.get('/hello')
        assert response.status_code == 200
        assert b"Hola Falabella!" in response.data
Example #8
0
def test_get_id_by_patente_upper_204():
    """
    Se debe obtener un status 204
    se utiliza la url /patente con el parametro patente
    en ABCD999 
    """
    with app.test_client() as test_client:
        response = test_client.get('/patente/?patente=ABCD999')
        assert response.status_code == 204
Example #9
0
def test_get_patente_by_id_204():
    """
    Se debe obtener un status 204 NO CONTENT
    al buscar la patente por el id 28888,.
    se utiliza la url /patente con el parametro id
    en 28888 
    """
    with app.test_client() as test_client:
        response = test_client.get('/patente/?id=28888')
        assert response.status_code == 204
Example #10
0
def test_get_patente_by_id_200():
    """
    Se debe obtener un status 200 y la patente AAAA000
    vinculada al id 1 en la base de datos,
    se utiliza la url /patente con el parametro id
    en 1 
    """
    with app.test_client() as test_client:
        response = test_client.get('/patente/?id=1')
        assert response.status_code == 200
        assert json.loads(response.data) == {'patente': "AAAA000"}
Example #11
0
def test_get_id_by_patente_upper_200():
    """
    Se debe obtener un status 200 y el id 26000
    vinculada al a la patente ZZZZ999 en la base de datos,
    se utiliza la url /patente con el parametro patente
    en ZZZZ999 
    """
    with app.test_client() as test_client:
        response = test_client.get('/patente/?patente=ZZZZ999')
        assert response.status_code == 200
        assert json.loads(response.data) == {'id': 26000}
Example #12
0
def test_post_entry():
    client = app.test_client()
    response = client.post('/add', data={'title': 'test title 1', 'text': 'test text 1'}, follow_redirect=True)
    assert response.status_code == 200
    assert "test title 1" in response.data
    assert "test text 1 " in response.data
    with app.test_request_context():
        assert Entry.query.count() == 1
        entry = Entry.query.get(1)
        entry.title = 'test title 1'
        entry.text = 'test text 1'
Example #13
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config['SQLALCHEMY_DATABASE_URI'] = database_uri

        self.app = app.test_client()

        self.new_author = {'mail': '*****@*****.**', 'name': 'author'}

        self.author = {'mail': '*****@*****.**', 'name': 'Ahmed'}
Example #14
0
def test_get_sum_matriz_18_200():
    """
    Se debe obtener una sumatoria de 18 al ingresar
    por parametros r, c, z, x, y:
    R = 4
    C = 3
    Z = 2
    X = 1
    Y = 2
    """
    with app.test_client() as test_client:
        response = test_client.get('/matriz/?r=4&c=3&z=2&x=1&y=2')
        assert response.status_code == 200
        assert json.loads(response.data) == {'resultado': 18}
Example #15
0
def test_get_sum_matriz_missing_200():
    """
    Se debe obtener un error de parametro que falta ingresar
    por parametros c, z, x, y:
    C = 3
    Z = 2
    X = 1
    Y = 2
    """
    with app.test_client() as test_client:
        response = test_client.get('/matriz/?c=3&z=2&x=1&y=2')
        assert response.status_code == 200
        assert json.loads(response.data) == {
            'error': 'Asegurece de ingresar los parametros r, c, z, x e y'
        }
Example #16
0
def test_get_sum_matriz_entero_200():
    """
    Se debe obtener un error de entero ingresar
    por parametros r, c, z, x, y:
    R = 4.1
    C = 3
    Z = 2
    X = 1
    Y = 2
    """
    with app.test_client() as test_client:
        response = test_client.get('/matriz/?r=4.1&c=3&z=2&x=1&y=2')
        assert response.status_code == 200
        assert json.loads(response.data) == {
            'error': 'Los parametros deben ser enteros'
        }
Example #17
0
def test_post_entry():
    client = app.test_client()
    response = client.post('/add',
                           data={
                               'title': 'test title 1',
                               'text': 'test text 1'
                           },
                           follow_redirect=True)
    assert response.status_code == 200
    assert "test title 1" in response.data
    assert "test text 1 " in response.data
    with app.test_request_context():
        assert Entry.query.count() == 1
        entry = Entry.query.get(1)
        entry.title = 'test title 1'
        entry.text = 'test text 1'
Example #18
0
 def test_index_login(self):
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertTrue(b'loGin here' in response.data)
Example #19
0
 def test_index_post(self):
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertTrue(b'redact' in response.data)
def client():
    """A test client for the app."""
    return app.test_client()
Example #21
0
def before_feature(context, feature):
    context.db, app.config['DATABASE'] = tempfile.mkstemp()
    app.testing = True
    context.client = app.test_client()
    with app.app_context():
        init_db()
 def setUp(self):
     """Set up test application client"""
     self.app = app.test_client()
     self.app.testing = True
Example #23
0
 def test_login_page(self):
     tester = app.test_client(self)
     response = tester.get('/login', content_type='html/text')
     self.assertTrue(b'Login' in response.data)
Example #24
0
 def setUp(self):
     self.db_fd, app.DATABASE = tempfile.mkstemp()
     self.app = app.test_client()
     db.create_all()
def before_feature(context, feature):
    app.config['TESTING'] = True
    context.db, app.config['DATABASE_PATH'] = tempfile.mkstemp()
    context.client = app.test_client()
    init_db()
Example #26
0
 def test_index(self):
     """initial test. ensure flask was set up correctly"""
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertEqual(response.status_code, 200)
def before_feature(context, feature):
    context.client = app.test_client()
Example #28
0
def before_feature(context, feature):
    context.client = app.test_client()
Example #29
0
 def test_website_online(self):
     tester = app.test_client(self)
     response = tester.get("/", content_type='html/text')
     self.assertEqual(response.status_code, 200)
Example #30
0
def client():
    app.config["TESTING"] = True
    with app.test_client() as client:
        yield client
from flaskr import app
# import pytest
import json

client = app.test_client()


def test_hello():
    response = client.get('/')
    assert response.status_code == 200
    assert response.data == b"Hello, World!"


def test_ctime():
    response = client.get('/ctime')
    assert response.status_code == 200
    assert b"The UTC time with format 'mm/dd/YYYY HH:MM:SS' is" in response.data


def test_invalid_zone():
    response = client.get('/ctime/some_invalid_tzone')
    assert response.status_code == 200
    assert b'Unknown time zone please provide valid timezone' in response.data
Example #32
0
def before_scenario(context,scenario):
	context.client = app.test_client()
	
	#Not use production db for tests
	app.config['DATABASE']=new_path+'test.db'
	context.database=new_path+'test.db'
Example #33
0
def before_feature(context, feature):
    # test the mock-up application
    app.config['TESTING'] = True
    context.db, app.config['DATABASE'] = tempfile.mkstemp()
    context.client = app.test_client()
    init_db()
Example #34
0
 def test_login_code(self):
     tester = app.test_client(self)
     response = tester.get('/login', content_type='html/text')
     self.assertEqual(response.status_code, 200)
def before_feature(context, feature):
    app.config['TESTING'] = True
    context.db, app.config['DATABASE'] = tempfile.mkstemp()
    context.client = app.test_client()
    init_db()
Example #36
0
 def setUp(self):
     app.testing = True
     self.app = app.test_client()