-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathtest_edit_profile.py
More file actions
214 lines (182 loc) · 7.7 KB
/
test_edit_profile.py
File metadata and controls
214 lines (182 loc) · 7.7 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import re
import pytest
from .. import factories as f
pytestmark = pytest.mark.django_db
def test_signup_college_poc_flow(base_url, browser, outbox):
f.create_usertype(slug='tutor', display_name='tutor')
user = f.create_user()
user.set_password('123123')
user.save()
url = base_url + '/accounts/login/'
browser.visit(url)
browser.fill('login', user.email)
browser.fill('password', '123123')
browser.find_by_css('[type=submit]')[0].click()
assert len(outbox) == 1
mail = outbox[0]
confirm_link = re.findall(r'http.*/accounts/.*/', mail.body)
assert confirm_link
browser.visit(confirm_link[0])
assert browser.title, "Confirm E-mail Address"
browser.find_by_css('[type=submit]')[0].click()
assert "Login" in browser.title
browser.fill('login', user.email)
browser.fill('password', '123123')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present("Dashboard")
poc_type = f.create_usertype(slug='poc', display_name='College POC')
user.profile.usertype.clear()
user.profile.usertype.add(poc_type)
user.profile.save()
user.save()
section1 = f.create_workshop_section(name='section1')
location1 = f.create_locaiton(name='location1')
state1 = f.create_state(name='state1')
# mobile number chechk
url = base_url + '/profile/' + user.username + '/edit'
browser.visit(url)
browser.fill('mobile', '')
browser.select('interested_sections', section1.id)
browser.select('location', location1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
# interested state check
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('location', location1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
# location check
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('location', location1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('location', location1.id)
# browser.fill('github', 'https://github.com')
browser.fill('first_name', 'First Name')
browser.fill('last_name', 'Last Name')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('Deactive Account')
def test_signup_tutor_flow(base_url, browser, outbox):
tutor_type = f.create_usertype(slug='tutor', display_name='tutor')
user = f.create_user()
user.set_password('123123')
user.save()
url = base_url + '/accounts/login/'
browser.visit(url)
browser.fill('login', user.email)
browser.fill('password', '123123')
browser.find_by_css('[type=submit]')[0].click()
assert len(outbox) == 1
mail = outbox[0]
confirm_link = re.findall(r'http.*/accounts/.*/', mail.body)
assert confirm_link
browser.visit(confirm_link[0])
assert browser.title, "Confirm E-mail Address"
browser.find_by_css('[type=submit]')[0].click()
assert "Login" in browser.title
browser.fill('login', user.email)
browser.fill('password', '123123')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present("Dashboard")
poc_type = f.create_usertype(slug='poc', display_name='College POC')
user.profile.usertype.clear()
user.profile.usertype.add(tutor_type)
user.profile.usertype.add(poc_type)
user.profile.save()
user.save()
section1 = f.create_workshop_section(name='section1')
location1 = f.create_locaiton(name='location1')
state1 = f.create_state(name='state1')
# mobile number chechk
url = base_url + '/profile/' + user.username + '/edit'
browser.visit(url)
browser.fill('mobile', '')
browser.select('usertype', tutor_type.id)
browser.select('interested_sections', section1.id)
browser.select('location', location1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
# interested state check
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('location', location1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
# location check
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
# Github check
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('location', location1.id)
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('Github or LinkedIn field is mandatory')
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('location', location1.id)
browser.fill('github', 'https://github.com')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present(
'Interested workshop level field is mandatory')
browser.visit(url)
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('interested_level', 1)
browser.select('location', location1.id)
browser.fill('github', 'https://github.com')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('This field is required.')
browser.visit(url)
browser.fill('first_name', 'First Name')
browser.fill('last_name', 'Last Name')
browser.fill('mobile', '1234567890')
browser.select('interested_sections', section1.id)
browser.select('interested_states', state1.id)
browser.select('interested_level', 1)
browser.select('location', location1.id)
browser.fill('github', 'https://github.com')
browser.find_by_css('[type=submit]')[0].click()
assert browser.is_text_present('Deactive Account')
org = f.create_organisation()
org.user.add(user)
# section2 = f.create_workshop_section(name='section2')
w1 = f.create_workshop(requester=org, workshop_section=section1)
w1.presenter.add(user)
w2 = f.create_workshop(requester=org, workshop_section=section1)
w2.presenter.add(user)
w3 = f.create_workshop(requester=org, workshop_section=section1)
w3.presenter.add(user)
w4 = f.create_workshop(requester=org, workshop_section=section1)
w4.presenter.add(user)
w5 = f.create_workshop(requester=org, workshop_section=section1)
w5.presenter.add(user)
url = base_url + '/profile/' + user.username + '/'
browser.visit(url)
assert browser.is_text_present('Deactive Account')