|
1
|
|
|
from datetime import datetime, timedelta |
|
2
|
|
|
|
|
3
|
|
|
import base |
|
4
|
|
|
from tests import factories as f |
|
5
|
|
|
from wye.base.constants import WorkshopStatus, WorkshopLevel |
|
6
|
|
|
from wye.workshops.tasks import workshop_reminder, workshop_feedback |
|
7
|
|
|
|
|
8
|
|
|
outbox_len = 0 |
|
9
|
|
|
password = '123123' |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
def test_workshop_celery_task(base_url, browser, outbox): |
|
13
|
|
|
""" |
|
14
|
|
|
""" |
|
15
|
|
|
|
|
16
|
|
|
# Create usertypes |
|
17
|
|
|
f.create_usertype( |
|
18
|
|
|
slug='lead', display_name='regional lead') |
|
19
|
|
|
f.create_usertype(slug='tutor', display_name='tutor') |
|
20
|
|
|
poc_type = f.create_usertype(slug='poc', display_name='poc') |
|
21
|
|
|
state = f.create_state() |
|
22
|
|
|
# Testcase with usertyep poc |
|
23
|
|
|
user = base.create_user(password) |
|
24
|
|
|
url = base_url + '/workshop/' |
|
25
|
|
|
base.login_and_confirm(browser, url, outbox, user, password) |
|
26
|
|
|
user.profile.usertype.clear() |
|
27
|
|
|
user.profile.usertype.add(poc_type) |
|
28
|
|
|
user.profile.interested_states.add(state) |
|
29
|
|
|
user.profile.save() |
|
30
|
|
|
user.save() |
|
31
|
|
|
|
|
32
|
|
|
# Create org |
|
33
|
|
|
location = f.create_locaiton(state=state) |
|
34
|
|
|
org = f.create_organisation(location=location) |
|
35
|
|
|
org.user.add(user) |
|
36
|
|
|
user.profile.interested_locations.add(location) |
|
37
|
|
|
user.profile.location = org.location |
|
38
|
|
|
user.profile.save() |
|
39
|
|
|
org.save() |
|
40
|
|
|
|
|
41
|
|
|
# Create workshop |
|
42
|
|
|
workshop = f.create_workshop(requester=org) |
|
43
|
|
|
workshop.expected_date = datetime.now() + timedelta(days=1) |
|
44
|
|
|
workshop.status = WorkshopStatus.REQUESTED |
|
45
|
|
|
workshop.level = WorkshopLevel.BEGINNER |
|
46
|
|
|
workshop.location = org.location |
|
47
|
|
|
workshop.presenter.add(user) |
|
48
|
|
|
workshop.save() |
|
49
|
|
|
|
|
50
|
|
|
rst = workshop_reminder.apply(args=(1, 1)).get() |
|
51
|
|
|
assert rst |
|
52
|
|
|
|
|
53
|
|
|
rst = workshop_reminder.apply(args=(1, 0)).get() |
|
54
|
|
|
assert rst |
|
55
|
|
|
|
|
56
|
|
|
workshop.expected_date = datetime.now() + timedelta(days=2) |
|
57
|
|
|
workshop.save() |
|
58
|
|
|
rst = workshop_feedback.apply(args=(1,)).get() |
|
59
|
|
|
assert rst |
|
60
|
|
|
# url = base_url + '/workshop/' |
|
61
|
|
|
# base.login(browser, url, user, password) |
|
62
|
|
|
# data_check = browser.find_by_text(org.name) |
|
63
|
|
|
# assert data_check |
|
64
|
|
|
|
|
65
|
|
|
# browser.visit(url + "?location={}".format(org.location.id)) |
|
66
|
|
|
# data_check = browser.find_by_text(org.name) |
|
67
|
|
|
# assert data_check |
|
68
|
|
|
|
|
69
|
|
|
# browser.visit(url + "?location={}".format(org.location.id + 1)) |
|
70
|
|
|
# data_check = browser.find_by_text(org.name) |
|
71
|
|
|
# assert not data_check |
|
72
|
|
|
|
|
73
|
|
|
# browser.visit(url + "?presenter={}".format(user.id)) |
|
74
|
|
|
# data_check = browser.find_by_text(org.name) |
|
75
|
|
|
# assert not data_check |
|
76
|
|
|
|
|
77
|
|
|
# browser.visit(url + "?status={}".format(WorkshopStatus.REQUESTED)) |
|
78
|
|
|
# data_check = browser.find_by_text(org.name) |
|
79
|
|
|
# assert data_check |
|
80
|
|
|
|
|
81
|
|
|
# browser.visit(url + "?level={}".format(WorkshopStatus.ACCEPTED)) |
|
82
|
|
|
# data_check = browser.find_by_text(org.name) |
|
83
|
|
|
# assert not data_check |
|
84
|
|
|
|
|
85
|
|
|
# # Testcase for usertype tutor |
|
86
|
|
|
# browser.visit(base_url + "/accounts/logout") |
|
87
|
|
|
# user = base.create_user(password) |
|
88
|
|
|
# url = base_url + '/workshop/' |
|
89
|
|
|
# base.login_and_confirm(browser, url, outbox, user, password) |
|
90
|
|
|
# # user.profile.usertype.add(tutor_type) |
|
91
|
|
|
# # user.save() |
|
92
|
|
|
|
|
93
|
|
|
# # url = base_url + '/workshop/' |
|
94
|
|
|
# # base.login(browser, url, user, password) |
|
95
|
|
|
# # # User not associate with workshop |
|
96
|
|
|
# # data_check = browser.find_by_text(org.name) |
|
97
|
|
|
# # assert [] == data_check |
|
98
|
|
|
|
|
99
|
|
|
# # User associated with workshop |
|
100
|
|
|
# workshop.presenter.add(user) |
|
101
|
|
|
# browser.visit(url) |
|
102
|
|
|
# # data_check = browser.find_by_text(org.name) |
|
103
|
|
|
# # assert data_check |
|
104
|
|
|
|
|
105
|
|
|
# # Testcase for lead |
|
106
|
|
|
# browser.visit(base_url + "/accounts/logout") |
|
107
|
|
|
# user = base.create_user(password) |
|
108
|
|
|
# url = base_url + '/workshop/' |
|
109
|
|
|
# base.login_and_confirm(browser, url, outbox, user, password) |
|
110
|
|
|
|
|
111
|
|
|
# user.profile.usertype.add(regional_lead_type) |
|
112
|
|
|
# user.save() |
|
113
|
|
|
# lead = RegionalLead.objects.create(location=org.location) |
|
114
|
|
|
# lead.leads.add(user) |
|
115
|
|
|
|
|
116
|
|
|
# url = base_url + '/workshop/' |
|
117
|
|
|
# base.login(browser, url, user, password) |
|
118
|
|
|
# # data_check = browser.find_by_text(org.name) |
|
119
|
|
|
# # assert data_check |
|
120
|
|
|
|
|
121
|
|
|
# # Testcase for user with no usertype |
|
122
|
|
|
# browser.visit(base_url + "/accounts/logout") |
|
123
|
|
|
# user = base.create_user(password) |
|
124
|
|
|
# url = base_url + '/workshop/' |
|
125
|
|
|
# base.login_and_confirm(browser, url, outbox, user, password) |
|
126
|
|
|
|
|
127
|
|
|
# url = base_url + '/workshop/' |
|
128
|
|
|
# base.login(browser, url, user, password) |
|
129
|
|
|
# # data_check = browser.find_by_text(org.name) |
|
130
|
|
|
# # assert [] == data_check |
|
131
|
|
|
# browser.visit(base_url + "/accounts/logout") |
|
132
|
|
|
|