Skip to content

Commit

Permalink
Update test for GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglenister committed Mar 12, 2024
1 parent 01f5c6d commit 9c16f9e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tests/views/test_files_page.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
from tests import PMGLiveServerTestCase
from universal_analytics import Tracker
from unittest.mock import patch


class TestFilesPage(PMGLiveServerTestCase):
@patch.object(Tracker, "send")
def test_questions_file_page(self, mock_tracker):
def test_questions_file_page(self):
"""
Test files page (/questions/<path>)
"""
path = "test_file.pdf"
response = self.make_request(f"/questions/{path}", follow_redirects=False)
mock_tracker.assert_called_with(
"file_download",
"/questions/test_file.pdf",
referrer="",
uip="127.0.0.1",
userAgent="werkzeug/2.0.0",
)

self.assertEqual(302, response.status_code)
self.assertEqual("http://pmg-assets.s3-website-eu-west-1.amazonaws.com/questions/test_file.pdf", response.location)
static_host = self.app.config.get("STATIC_HOST")
self.assertEqual(response.location, f"{static_host}questions/{path}")

0 comments on commit 9c16f9e

Please sign in to comment.