summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py29
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: