def test_add_p_in_name_to_char_with_yellow_hat(testapp):
    request_data = {
        'name': 'Leo',
        'age': 23,
        'weight': 66.5,
        'human': True,
        'hat':  {
            'color': 'YELLOW'
        }
    }
    testapp.post('/character/', content_type='application/json',
                 data=json.dumps(request_data))
    request_data = {
        'name': 'Pierre'
    }
    resp = testapp.put('/character/6', content_type='application/json',
                       data=json.dumps(request_data))
    # Tests
    assert resp.status_code == 400
    assert CharacterModel.get_char(6).name == 'Leo'
Esempio n. 2
0
def test_create_yellow_hat_to_p_name_char(testapp):
    request_data = {
        'name': 'Pierre',
        'age': 23,
        'weight': 66.5,
        'human': True,
    }
    testapp.post('/character/',
                 content_type='application/json',
                 data=json.dumps(request_data))

    request_data = {'color': 'YELLOW', 'character_id': 1}
    resp = testapp.post('/hat/',
                        content_type='application/json',
                        data=json.dumps(request_data))

    # Tests
    assert resp.status_code == 400
    assert CharacterModel.get_char(10)
    assert not HatModel.get_hat(3)
Esempio n. 3
0
def test_create_hat_to_char_with_hat(testapp):
    request_data = {
        'name': 'Leo',
        'age': 23,
        'weight': 65.5,
        'human': True,
        'hat': {
            'color': 'PURPLE'
        }
    }
    testapp.post('/character/',
                 content_type='application/json',
                 data=json.dumps(request_data))

    request_data = {'color': 'GREEN', 'character_id': 12}
    resp = testapp.post('/hat/',
                        content_type='application/json',
                        data=json.dumps(request_data))

    # Tests
    assert resp.status_code == 400
    assert CharacterModel.get_char(12)
    assert HatModel.get_hat(5)
    assert not HatModel.get_hat(6)
def test_delete_char_doesnt_exit(testapp):
    resp = testapp.delete('/character/1')

    # Tests
    assert resp.status_code == 400
    assert not CharacterModel.get_char(1)