dimanche 25 janvier 2015

Test a login required Flask application

I want to test a Flask app needs login to work i created the login test class:



class TestLogin(unittest.TestCase):
def setUp(self):
self.headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}

def test_admin_login_with_default_password(self):

s = rq.Session()
url = 'http://localhost/api/v1/user/login/'
data = {'username': 'admin', 'password': ''}
r = s.post(url, data=json.dumps(data), headers=self.headers)
self.assertEqual(r.status_code, 200)


on other tests i need to login again how can i do this easy before running every test ?


Aucun commentaire:

Enregistrer un commentaire