From 867e177c90f61b1ca1c14a3e001ae72cfbce66ef Mon Sep 17 00:00:00 2001 From: sqozz Date: Sat, 7 Apr 2018 21:31:29 +0200 Subject: [PATCH] Add simple function tests --- schort_functional_tests.py | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 schort_functional_tests.py diff --git a/schort_functional_tests.py b/schort_functional_tests.py new file mode 100755 index 0000000..c9ae47e --- /dev/null +++ b/schort_functional_tests.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +import os +import unittest +import requests + +BASE_URL="http://localhost:5000" + +class SchortFunctionalTestCase(unittest.TestCase): + def setUp(self): + # maybe later + pass + + def tearDown(self): + # maybe later + pass + + def assertPostReq(self, url, data = {}): + req = requests.post(url, data=data) + self.assertEqual(req.status_code, 200) + return req + + def assertGetReq(self, url, params = {}): + req = requests.get(url, params=params) + self.assertEqual(req.status_code, 200) + return req + + def test_entry_page(self): + req = self.assertGetReq(BASE_URL + "/") + + def test_custom_creation(self): + req = self.assertPostReq(BASE_URL + "/", data={"url" : "https://github.com/sqozz/schort", "wishId" : "custom_user_supplied_url"}) + + def test_easy_api(self): + ''' + Test if the api is intuitive/easy to implement + + While creating the custom_creation test, out of pure laziness, I left out the whishId parameter. + For intuitive use of the API from a script, this shouldn't be neccessary. + ''' + req = self.assertPostReq("http://localhost:5000/", data={"url" : "https://github.com/sqozz/schort"}) + + +if __name__ == '__main__': + unittest.main() + +# vim: noexpandtab:ts=2:sw=2:sts=2