def test_put_wrong_path(self): """Tests sending a wrong path""" resp = req.put(settings.get_base_url() + "/goodbye/Basil", data='{ "dateOfBirth": "2014-05-01" }', headers={'Content-type': 'application/json'}) assert 400 == resp.status_code
def test_put_wrong_name(self): """Tests sending a malformed name""" resp = req.put(settings.get_base_url() + "/hello/Basil2", data='{ "dateOfBirth": "2014-05-01" }', headers={'Content-type': 'application/json'}) assert 400 == resp.status_code
def test_put_wrong_date_key(self): """Tests sending wrong JSON key""" resp = req.put(settings.get_base_url() + "/hello/Basil", data='{ "dateOfBIRTH": "2014-05-01" }', headers={'Content-type': 'application/json'}) assert 400 == resp.status_code
def test_get(self): """Tests HTTP get request method""" resp = req.get(settings.get_base_url() + "/hello/Basil") assert 200 == resp.status_code today = datetime.date.today() date_of_birth = datetime.datetime(2014, 5, 1).date() next_birthday = datetime.datetime(today.year + 1, date_of_birth.month, date_of_birth.day).date() days = (next_birthday - today).days if days > 0: assert '{ "message": "Hello, Basil! Your birthday is in %s day(s)" }' % str( days) == resp.text else: assert '{ "message": "Hello, Basil! Happy birthday!" }' == resp.text
def test_get_another_user(self): """Tests HTTP get request method""" resp = req.get(settings.get_base_url() + "/hello/Pafnuty") assert 200 == resp.status_code
def test_get_missed_user(self): """Tests getting missed user""" resp = req.get(settings.get_base_url() + "/hello/Zeliboba") assert 404 == resp.status_code