Ejemplo n.º 1
0
def test_profile(client):
    client.post('/login', data={"name": "Test User", "email": "*****@*****.**",
                                "password": "******"}, follow_redirects=True)

    user = db.query(User).first()
    response = client.get('/profile/')

    assert ("Test User" in str(response.data))
Ejemplo n.º 2
0
def test_user_details(client):
    client.post('/login', data={"name": "Test User", "email": "*****@*****.**",
                                "password": "******"}, follow_redirects=True)

    user = db.query(User).first()

    response = client.get('/profiles/{}'.format(user.uid))
    assert b'*****@*****.**' in response.data
    assert b'Test User' in response.data
Ejemplo n.º 3
0
def test_result_incorrect_smaller(client):
    login(client)
    user = db.query(User).first()
    user.secret_number = 10

    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 20})
    assert b'Your guess is not correct... try something smaller' in response.data
Ejemplo n.º 4
0
def test_result_correct(client):
    login(client)
    user = db.query(User).first()
    user.secret_number = 10

    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 10})

    assert b'Correct! The secret number is 10' in response.data
Ejemplo n.º 5
0
def test_user_details(client):
    # create a new user
    client.post('/login', data={"user-name": "Test User", "user-email": "*****@*****.**",
                                "user-password": "******"}, follow_redirects=True)

    # get user object from the database
    user = db.query(User).first()

    response = client.get('/user/{}'.format(user.id))
    assert b'*****@*****.**' in response.data
    assert b'Test User' in response.data
Ejemplo n.º 6
0
def test_result_correct(client):
    client.post('/login', data={"name": "Test User", "email": "*****@*****.**",
                                "password": "******"}, follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/', data={"ugibanje": 22})

    assert b'Bravo, zadel si' in response.data
Ejemplo n.º 7
0
def test_result_incorrect_try_smaller(client):
    client.post('/login', data={"name": "Test User", "email": "*****@*****.**",
                                "password": "******"}, follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/', data={"ugibanje": 23})

    assert ("Number is too big" in str(response.data))
Ejemplo n.º 8
0
def test_result_incorrect_try_smaller(client):
    # create a user
    client.post('/login', data={"user-name": "Test User", "user-email": "*****@*****.**",
                                "user-password": "******"}, follow_redirects=True)

    # get user object from the database
    user = db.query(User).first()

    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 27})  # enter the wrong guess (too big)
    assert b'Your guess is not correct... try something smaller.' in response.data
Ejemplo n.º 9
0
def test_user_mock_db():

    user = Mock()

    user.name = "rubenXR"
    user.email = "*****@*****.**"
    user.password = "******"
    user.secret_number = "15"
    user.delete = False

    user = db.query(User).first()

    db.add(user)
    db.commit()
Ejemplo n.º 10
0
def test_result_correct(client):
    # create a user
    client.post('/login', data={"user-name": "Test User", "user-email": "*****@*****.**",
                                "user-password": "******"}, follow_redirects=True)

    # get the first (and only) user object from the database
    user = db.query(User).first()

    # set the secret number to 22, so that you can make a success "guess" in the test.
    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 22})  # enter the correct guess
    assert b'Correct! The secret number is 22' in response.data
Ejemplo n.º 11
0
def test_result_correct(client):
    client.post("/login",
                data={
                    "user-name": "Test123",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 17
    db.add(user)
    db.commit()

    response = client.post("/result", data={"quess": 17})
    assert b'Ci' in response.data
Ejemplo n.º 12
0
def test_secret_number_correct(client):
    client.post('/login',
                data={
                    "user-name": "ruben",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 30
    db.add(user)
    db.commit()

    response = client.post('/result', data={"num_user": 30})
    assert b'Enhorabuena!! El numero correcto es: 30' in response.data
Ejemplo n.º 13
0
def test_result_incorrect_try_smaller(client):
    client.post('/login',
                data={
                    "user-name": "Test User",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 13})
    assert b'your guess is not correct... try something smaller.' in response.data
Ejemplo n.º 14
0
def test_result_try_lower(client):
    client.post('/login',
                data={
                    "user-name": "user",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 2

    db.add(user)
    db.commit()

    response = client.post('/result', data={"quess": 28})
    assert b'Twoja liczba jest zbyt mala' in response.data
Ejemplo n.º 15
0
def test_result_correct(client):
    # create a user
    client.post('/login',
                data={
                    "user-name": "Test User",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    user = db.query(User).first()

    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess":
                                            22})  # enter the correct guess
    assert b'Correct! The secret number is 22' in response.data
Ejemplo n.º 16
0
def test_result_te_klein(client):
    # create a user
    client.post('/login',
                data={
                    "user-name": "TestUser",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    # get the first (and only) user object from the database
    user = db.query(User).first()

    # set the secret number to 22, so that you can make a success "guess" in the test.
    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess": 20})  # guess is too small
    assert b'try something bigger.' in response.data
Ejemplo n.º 17
0
def test_result_out_of_bound_high(client):
    # create a user
    client.post('/login',
                data={
                    "user-name": "TestUser",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    # get the first (and only) user object from the database
    user = db.query(User).first()

    # set the secret number to 22, so that you can make a success "guess" in the test.
    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess":
                                            31})  # guess is out of bound
    assert b'Het getal moet tussen 1 en 30 liggen.' in response.data
Ejemplo n.º 18
0
def test_result_geen_getal(client):
    # create a user
    client.post('/login',
                data={
                    "user-name": "TestUser",
                    "user-email": "*****@*****.**",
                    "user-password": "******"
                },
                follow_redirects=True)

    # get the first (and only) user object from the database
    user = db.query(User).first()

    # set the secret number to 22, so that you can make a success "guess" in the test.
    user.secret_number = 22
    db.add(user)
    db.commit()

    response = client.post('/result', data={"guess":
                                            "Axel"})  # guess is geen getal
    assert b'Dat was geen (geheel) getal.' in response.data
Ejemplo n.º 19
0
 def by_id(cls, item_id, deleted=False):
     item = db.query(cls).get(item_id)
     if not item or (item.deleted and not deleted):
         raise shake.NotFound
     return item
Ejemplo n.º 20
0
 def by_login(cls, login):
     login = to_unicode(login)
     return db.query(cls).filter(cls.login == login).first()
Ejemplo n.º 21
0
 def by_name(cls, name):
     name = to_unicode(name)
     return db.query(cls).filter(cls.name == name).first()
Ejemplo n.º 22
0
 def delete_all(cls, ids):
     ids = list(ids)
     if not ids:
         return
     db.query(cls).filter(cls.id.in_(ids)).delete(synchronize_session='fetch')
Ejemplo n.º 23
0
 def by_id(cls, item_id, deleted=False):
     item = db.query(cls).get(item_id)
     if not item or (item.deleted and not deleted):
         raise shake.NotFound
     return item
Ejemplo n.º 24
0
 def get_all(cls, deleted=False):
     query = db.query(cls)
     if deleted is not None:
         query = query.filter(cls.deleted == deleted)
     return query
Ejemplo n.º 25
0
 def get_all_in(cls, ids, deleted=False):
     query = db.query(cls).filter(cls.id.in_(ids))
     if deleted is not None:
         query = query.filter(cls.deleted == deleted)
     return query
Ejemplo n.º 26
0
 def get_all(cls, deleted=False):
     query = db.query(cls)
     if deleted is not None:
         query = query.filter(cls.deleted == deleted)
     return query
Ejemplo n.º 27
0
 def get_all_in(cls, ids, deleted=False):
     query = db.query(cls).filter(cls.id.in_(ids))
     if deleted is not None:
         query = query.filter(cls.deleted == deleted)
     return query
Ejemplo n.º 28
0
 def by_slug(cls, slug):
     return db.query(cls).filter(cls.slug == slug).first()
Ejemplo n.º 29
0
 def by_slug(cls, slug):
     return db.query(cls).filter(cls.slug == slug).first()
Ejemplo n.º 30
0
 def delete_all(cls, ids):
     ids = list(ids)
     if not ids:
         return
     db.query(cls).filter(
         cls.id.in_(ids)).delete(synchronize_session='fetch')