-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtest_cpl.py
More file actions
76 lines (49 loc) · 2.63 KB
/
test_cpl.py
File metadata and controls
76 lines (49 loc) · 2.63 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import pytest
from django.urls import reverse
from pythonpro.django_assertions import dj_assert_contains
from pythonpro.launch.facade import (
LAUNCH_STATUS_CPL1,
LAUNCH_STATUS_CPL2,
LAUNCH_STATUS_CPL3,
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 resp_on_cpl1_on_air(mocker, client, tag_as_mock):
mocker.patch('pythonpro.launch.facade.get_launch_status', return_value=LAUNCH_STATUS_CPL1)
mocker.patch('pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_CPL1)
return client.get(reverse('launch:cpl1'))
def test_cpl_video_is_present(resp_on_cpl1_on_air):
dj_assert_contains(resp_on_cpl1_on_air, 'https://www.youtube.com/embed/')
def test_facebook_comments_is_present(resp_on_cpl1_on_air):
dj_assert_contains(resp_on_cpl1_on_air, 'www.facebook.com/v4.0/plugins/comments.php')
def test_should_return_cpl1_on_air_in_navbar(resp_on_cpl1_on_air):
dj_assert_contains(resp_on_cpl1_on_air, reverse('launch:cpl1'))
@pytest.fixture
def resp_on_cpl2_on_air(mocker, client, tag_as_mock):
mocker.patch('pythonpro.launch.facade.get_launch_status', return_value=LAUNCH_STATUS_CPL2)
mocker.patch('pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_CPL2)
return client.get(reverse('launch:cpl2'))
def test_should_return_cpl2_on_air_in_navbar(resp_on_cpl2_on_air):
dj_assert_contains(resp_on_cpl2_on_air, reverse('launch:cpl2'))
@pytest.fixture
def resp_on_cpl3_on_air(mocker, client, tag_as_mock):
mocker.patch('pythonpro.launch.facade.get_launch_status', return_value=LAUNCH_STATUS_CPL3)
mocker.patch('pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_CPL3)
return client.get(reverse('launch:cpl3'))
def test_should_return_cpl3_on_air_in_navbar(resp_on_cpl3_on_air):
dj_assert_contains(resp_on_cpl3_on_air, reverse('launch:cpl3'))
@pytest.fixture
def resp_on_cpl4_on_air(mocker, client, tag_as_mock):
mocker.patch('pythonpro.launch.facade.get_launch_status', return_value=LAUNCH_STATUS_CPL4)
mocker.patch('pythonpro.launch.views.get_launch_status', return_value=LAUNCH_STATUS_CPL4)
return client.get(reverse('launch:cpl4'))
def test_should_return_cpl4_on_air_in_navbar(resp_on_cpl4_on_air):
dj_assert_contains(resp_on_cpl4_on_air, reverse('launch:cpl4'))
@pytest.fixture
def resp_cpl_with_debug(mocker, client, tag_as_mock):
return client.get(reverse('launch:cpl1') + '?debug=1')
def test_should_return_cpl_when_debug_is_true(resp_cpl_with_debug):
assert resp_cpl_with_debug.status_code == 200