diff tests/suite_12_methods/__init__.py @ 71:88adf10be709 draft

Add tests.
author David Barts <n5jrn@me.com>
date Mon, 15 Jul 2019 13:16:31 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/suite_12_methods/__init__.py	Mon Jul 15 13:16:31 2019 -0700
@@ -0,0 +1,35 @@
+# I m p o r t s
+
+import os, sys
+import requests
+import urllib.parse
+from bs4 import BeautifulSoup
+from .. import ServerFixture, RoutesFixture
+
+# C l a s s e s
+
+class Fixture01(RoutesFixture):
+    def _doform(self, page):
+        url = "http://localhost:{0}/{1}".format(self.port, page)
+        response = requests.get(url)
+        self.assertEqual(response.status_code, 200)
+        soup = BeautifulSoup(response.text, 'html.parser')
+        self.assertIsNotNone(soup.find(
+            "input", attrs={"type": "text", "name": "name"}))
+        self.assertIsNotNone(soup.find(
+            "input", attrs={"type": "submit", "value": "Submit"}))
+        form = soup.find("form")
+        self.assertIsNotNone(form)
+        action_url = urllib.parse.urljoin(url, form.get("action", page))
+        response = requests.post(url, {"name": "Barney Dinosaur"})
+        self.assertEqual(response.status_code, 200)
+        self.assertTrue("Hello, Barney" in response.text)
+        self.assertTrue("Pleased to meet you!" in response.text)
+
+    # Methods with their standard, uppercase names
+    def test_01_methods(self):
+        self._doform("name.pspx")
+
+    # Methods with alternate capitalizations. This also tests #python
+    def test_02_methods_lc(self):
+        self._doform("name_lc.pspx")