Skip to content

Commit

Permalink
Test AmplitudeException caught in send page view event middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
pyepye committed Jul 28, 2020
1 parent 972942d commit 384498a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "django-amplitude"
packages = [
{include = "amplitude"}
]
version = "0.4.0"
version = "0.5.0"
description = "Integration between Django and Amplitude"
authors = ["Matt Pye <[email protected]>"]
readme = "README.md"
Expand Down
10 changes: 8 additions & 2 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

from importlib import reload
from urllib.parse import urlencode

from django.conf import settings
from django.urls import reverse
from httpx import HTTPError

from .fixtures import user # NOQA: F401


AMPLITUDE_URL = 'https://api.amplitude.com/2/httpapi'


Expand Down Expand Up @@ -212,3 +211,10 @@ def test_send_page_view_event_no_auth_middleware(

client.get(url)
request.assert_called_once_with(**kwargs)


def test_send_page_view_event_httpx_error(mocker, client):
mock = mocker.Mock()
mock.raise_for_status.side_effect = HTTPError()
mocker.patch('amplitude.amplitude.httpx.request', return_value=mock)
client.get('')

0 comments on commit 384498a

Please sign in to comment.