comparison 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
comparison
equal deleted inserted replaced
70:a78c74c73d98 71:88adf10be709
1 # I m p o r t s
2
3 import os, sys
4 import requests
5 import urllib.parse
6 from bs4 import BeautifulSoup
7 from .. import ServerFixture, RoutesFixture
8
9 # C l a s s e s
10
11 class Fixture01(RoutesFixture):
12 def _doform(self, page):
13 url = "http://localhost:{0}/{1}".format(self.port, page)
14 response = requests.get(url)
15 self.assertEqual(response.status_code, 200)
16 soup = BeautifulSoup(response.text, 'html.parser')
17 self.assertIsNotNone(soup.find(
18 "input", attrs={"type": "text", "name": "name"}))
19 self.assertIsNotNone(soup.find(
20 "input", attrs={"type": "submit", "value": "Submit"}))
21 form = soup.find("form")
22 self.assertIsNotNone(form)
23 action_url = urllib.parse.urljoin(url, form.get("action", page))
24 response = requests.post(url, {"name": "Barney Dinosaur"})
25 self.assertEqual(response.status_code, 200)
26 self.assertTrue("Hello, Barney" in response.text)
27 self.assertTrue("Pleased to meet you!" in response.text)
28
29 # Methods with their standard, uppercase names
30 def test_01_methods(self):
31 self._doform("name.pspx")
32
33 # Methods with alternate capitalizations. This also tests #python
34 def test_02_methods_lc(self):
35 self._doform("name_lc.pspx")