def test_it_shows_one_book(client): book = {'title': 'Test Book'} client.post('/books/form', data=book) expected_text = '<h2 class="bookery-subtitle">"Test Book"</h2>' response = client.get('/books/1') assert response.status_code == 200 assert expected_text in response.get_data(as_text=True)
def test_it_gets_edit_receiver_form(client): receiver = {'name': 'Paweł', 'surname': 'Niesiołowski'} client.post('/receivers/form', data=receiver) response = client.get('/receivers/1/form') expected_text = '<h2 class="bookery-subtitle">\ Edytuj dane użytkownika: Paweł Niesiołowski</h2>' assert response.status_code == 200 assert expected_text in response.get_data(as_text=True)
def test_it_gets_edit_receiver_form(client): book = {'title': 'Test Book'} client.post('/books/form', data=book) response = client.get('/books/1/form') expected_text = '<h2 class="bookery-subtitle">\ Edytuj książkę: Test Book</h2>' assert response.status_code == 200 assert expected_text in response.get_data(as_text=True)
def test_it_gets_receivers_data(client): client.post('/receivers/form', data={ 'name': 'Paweł', 'surname': 'Niesiołowski' }) client.post('/receivers/form', data={ 'name': 'Justyna', 'surname': 'Mazur' }) response = client.get('/receivers') data = response.get_json() assert response.status_code == 200 assert data['status'] == 200 assert len(data['data']) == 2
def test_hello_world(client): ret = client.get("/") assert b"Hello World!" == ret.data
def test_it_gets_new_receiver_form(client): response = client.get('/receivers/form') expected_text = '<h2 class="bookery-subtitle">Dodaj użytkownika</h2>' assert response.status_code == 200 assert expected_text in response.get_data(as_text=True)
def test_it_returns_false_if_book_with_given_title_does_not_exist(client): book = {'title': 'Test Book'} client.post('/books/form', data=book) response = client.get('/books/Test Book 2/exists') assert response.status_code == 200 assert response.get_json()['data'] is False