Skip to content

Commit

Permalink
Merge pull request #597 from nationalarchives/bugfix/fix-brittle-judg…
Browse files Browse the repository at this point in the history
…ment-test

Fail judgment test fast if environment misconfigured
  • Loading branch information
jacksonj04 authored Mar 20, 2023
2 parents c5a44ad + 2d31fd3 commit 099708a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion judgments/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from os import environ
from unittest import skip
from unittest.mock import Mock, patch

Expand Down Expand Up @@ -124,14 +125,16 @@ class TestJudgment(TestCase):
@patch("judgments.views.detail.decoder.MultipartDecoder")
@patch("judgments.views.detail.api_client")
def test_valid_content(self, client, decoder, head):
if "ASSETS_CDN_BASE_URL" not in environ:
raise "ensure ASSETS_CDN_BASE_URL is set in .env!"
head.return_value.headers = {"Content-Length": "1234567890"}
client.eval_xslt.return_value = "eval_xslt"
decoder.MultipartDecoder.from_response.return_value.parts[0].text = "part0text"
client.get_judgment_name.return_value = "judgment metadata"

response = self.client.get("/ewca/civ/2004/632")
decoded_response = response.content.decode("utf-8")
self.assertIn("assets.caselaw.nationalarchives.gov.uk", decoded_response)
self.assertIn(environ["ASSETS_CDN_BASE_URL"], decoded_response)
self.assertIn("ewca_civ_2004_632.pdf", decoded_response)
self.assertNotIn("data.pdf", decoded_response)
self.assertIn("(1.1\xa0GB)", decoded_response)
Expand Down

0 comments on commit 099708a

Please sign in to comment.