diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-22 19:42:53 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-22 19:42:53 +0100 |
commit | 0d679fdaa3bb202eed7e77eb4112ac05f5e7c49b (patch) | |
tree | 6c9e3afb730bbd32f3ff99669693adde8200f72a /archaeological_operations/tests.py | |
parent | ea1e2867a192d0f57de0b4690131037020cda211 (diff) | |
download | Ishtar-0d679fdaa3bb202eed7e77eb4112ac05f5e7c49b.tar.bz2 Ishtar-0d679fdaa3bb202eed7e77eb4112ac05f5e7c49b.zip |
Fix tests
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index a9fe8760e..7bc51539d 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -16,6 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # See the file COPYING for details. +from bs4 import BeautifulSoup import json import datetime from subprocess import Popen, PIPE @@ -4041,10 +4042,16 @@ class DocumentTest(OperationInitTest, TestCase): c.login(username=self.username, password=self.password) response = c.get(url, {"operation": self.operation.pk}) self.assertEqual(response.status_code, 200) - self.assertIn( - 'option value="{}" selected'.format(self.operation.pk), - response.content.decode(), - ) + + result = response.content.decode() + soup = BeautifulSoup(result, "lxml") + ok = False + for field in soup.findAll("option"): + keys = list(field.attrs.keys()) + if "selected" in keys and "value" in keys and field["value"] == str(self.operation.pk): + ok = True + break + self.assertTrue(ok, msg="Operation not selected in Document form") posted = {"authors": []} for related_key in models.Document.RELATED_MODELS: @@ -4079,10 +4086,16 @@ class DocumentTest(OperationInitTest, TestCase): c.login(username=self.username, password=self.password) response = c.get(url) self.assertEqual(response.status_code, 200) - self.assertIn( - 'option value="{}" selected'.format(self.operation.pk), - response.content.decode(), - ) + + result = response.content.decode() + soup = BeautifulSoup(result, "lxml") + ok = False + for field in soup.findAll("option"): + keys = list(field.attrs.keys()) + if "selected" in keys and "value" in keys and field["value"] == str(self.operation.pk): + ok = True + break + self.assertTrue(ok, msg="Operation not selected in Document form") posted = {"authors": [], "title": "hop2-is-back"} for related_key in models.Document.RELATED_MODELS: |