Exemple #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))
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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))
Exemple #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
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()
Exemple #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
Exemple #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
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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #20
0
 def by_login(cls, login):
     login = to_unicode(login)
     return db.query(cls).filter(cls.login == login).first()
Exemple #21
0
 def by_name(cls, name):
     name = to_unicode(name)
     return db.query(cls).filter(cls.name == name).first()
Exemple #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')
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #28
0
 def by_slug(cls, slug):
     return db.query(cls).filter(cls.slug == slug).first()
Exemple #29
0
 def by_slug(cls, slug):
     return db.query(cls).filter(cls.slug == slug).first()
Exemple #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')