-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtest_cpl4.py
More file actions
59 lines (36 loc) · 1.55 KB
/
test_cpl4.py
File metadata and controls
59 lines (36 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pytest
from django.urls import reverse
from pythonpro.domain.user_domain import find_user_interactions
from pythonpro.launch.facade import LAUNCH_STATUS_OPEN_CART, LAUNCH_STATUS_CPL4
@pytest.fixture
def tag_as_mock(mocker):
return mocker.patch('pythonpro.domain.user_domain._email_marketing_facade.tag_as.delay')
@pytest.fixture
def launch_status_as_mock(mocker):
return mocker.patch(
'pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_OPEN_CART
)
@pytest.fixture
def resp(client, tag_as_mock, launch_status_as_mock):
return client.get(reverse('launch:cpl4'))
def test_status_code(resp):
assert 302 == resp.status_code
def test_email_marketing_tag_not_called(resp, tag_as_mock):
assert tag_as_mock.call_count == 0
@pytest.fixture
def resp_with_user(client_with_user, tag_as_mock):
return client_with_user.get(reverse('launch:cpl3'))
def test_user_interaction(resp_with_user, logged_user):
assert 'CPL3' in [i.category for i in find_user_interactions(logged_user)]
def test_email_marketing_tag(resp_with_user, logged_user, tag_as_mock):
tag_as_mock.assert_called_once_with(logged_user.email, logged_user.id, 'cpl3')
@pytest.fixture
def launch_status_as_mock_open(mocker):
return mocker.patch(
'pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_CPL4
)
@pytest.fixture
def resp_open(client, tag_as_mock, launch_status_as_mock_open):
return client.get(reverse('launch:cpl4'))
def test_open_status_code(resp_open):
assert 200 == resp_open.status_code