test_signup_college_poc_flow()   C
last analyzed

Complexity

Conditions 7

Size

Total Lines 75

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 75
rs 5.3953
cc 7

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
2
3
import pytest
4
5
from .. import factories as f
6
from .. utils import create_user_verify_login
7
pytestmark = pytest.mark.django_db
8
9
10
def create_user_type(slug='tutor'):
11
    tutor_type = f.create_usertype(slug=slug, display_name=slug)
12
    return tutor_type
13
14
15
def test_signup_college_poc_flow(base_url, browser, outbox):
16
    tutor_type = create_user_type(slug='tutor')
17
    print(tutor_type)
18
    user = create_user_verify_login(base_url, browser, outbox)
19
    browser.fill('login', user.email)
20
    browser.fill('password', '123123')
21
    browser.find_by_css('[type=submit]')[0].click()
22
    # assert browser.is_text_present("My Profile")
23
24
    poc_type = f.create_usertype(slug='poc', display_name='College POC')
25
    user.profile.usertype.clear()
26
    user.profile.usertype.add(poc_type)
27
    user.profile.save()
28
    user.save()
29
    section1 = f.create_workshop_section(name='section1')
30
31
    location1 = f.create_locaiton(name='location1')
32
    state1 = f.create_state(name='state1')
33
34
    # mobile number chechk
35
    url = base_url + '/profile/' + user.username + '/edit/'
36
    browser.visit(url)
37
    browser.fill('mobile', '')
38
    browser.select('interested_sections', section1.id)
39
    browser.select('location', location1.id)
40
    browser.select('interested_states', state1.id)
41
    browser.find_by_css('[type=submit]')[0].click()
42
    assert browser.is_text_present('This field is required.')
43
44
    # interested state check
45
    browser.fill('mobile', '1234567890')
46
    browser.select('location', location1.id)
47
    browser.select('interested_states', state1.id)
48
    browser.find_by_css('[type=submit]')[0].click()
49
    assert browser.is_text_present('This field is required.')
50
51
    # location check
52
    browser.fill('mobile', '1234567890')
53
    browser.select('interested_sections', section1.id)
54
    browser.select('interested_states', state1.id)
55
    browser.find_by_css('[type=submit]')[0].click()
56
    assert browser.is_text_present('This field is required.')
57
58
    # Use first name and last name
59
    browser.fill('mobile', '1234567890')
60
    browser.select('interested_sections', section1.id)
61
    browser.select('interested_states', state1.id)
62
    browser.select('location', location1.id)
63
    browser.find_by_css('[type=submit]')[0].click()
64
    assert browser.is_text_present('This field is required.')
65
66
    # occupation is required
67
    browser.fill('first_name', 'First Name')
68
    browser.fill('last_name', 'Last Name')
69
    browser.fill('mobile', '1234567890')
70
    browser.select('interested_sections', section1.id)
71
    browser.select('interested_states', state1.id)
72
    browser.select('location', location1.id)
73
    browser.find_by_css('[type=submit]')[0].click()
74
    assert browser.is_text_present('This field is required.')
75
76
    # Sucess case
77
    browser.visit(url)
78
    browser.fill('first_name', 'First Name')
79
    browser.fill('last_name', 'Last Name')
80
    browser.fill('mobile', '1234567890')
81
    browser.fill('occupation', 'occupation')
82
    browser.fill('work_location', 'work_location')
83
    browser.fill('work_experience', 1)
84
    browser.select('interested_sections', section1.id)
85
    browser.select('interested_states', state1.id)
86
    browser.select('location', location1.id)
87
    browser.find_by_css('[type=submit]')[0].click()
88
89
    assert browser.is_text_present('Deactive Account')
90
91
92
def test_signup_tutor_flow(base_url, browser, outbox):
93
    tutor_type = create_user_type(slug='tutor')
94
    user = create_user_verify_login(base_url, browser, outbox)
95
96
    browser.fill('login', user.email)
97
    browser.fill('password', '123123')
98
    browser.find_by_css('[type=submit]')[0].click()
99
100
    # assert browser.is_text_present("My Profile")
101
    poc_type = f.create_usertype(slug='poc', display_name='College POC')
102
    user.profile.usertype.clear()
103
    user.profile.usertype.add(tutor_type)
104
    user.profile.usertype.add(poc_type)
105
    user.profile.save()
106
    user.save()
107
    section1 = f.create_workshop_section(name='section1')
108
    location1 = f.create_locaiton(name='location1')
109
    state1 = f.create_state(name='state1')
110
111
    # mobile number chechk
112
    url = base_url + '/profile/' + user.username + '/edit'
113
    browser.visit(url)
114
    browser.fill('mobile', '')
115
    browser.select('usertype', tutor_type.id)
116
    browser.select('interested_sections', section1.id)
117
    browser.select('location', location1.id)
118
    browser.select('interested_states', state1.id)
119
    browser.find_by_css('[type=submit]')[0].click()
120
    assert browser.is_text_present('This field is required.')
121
122
    # interested state check
123
    browser.visit(url)
124
    browser.fill('mobile', '1234567890')
125
    browser.select('location', location1.id)
126
    browser.select('interested_states', state1.id)
127
    browser.find_by_css('[type=submit]')[0].click()
128
    assert browser.is_text_present('This field is required.')
129
130
    # location check
131
    browser.visit(url)
132
    browser.fill('mobile', '1234567890')
133
    browser.select('interested_sections', section1.id)
134
    browser.select('interested_states', state1.id)
135
    browser.find_by_css('[type=submit]')[0].click()
136
    assert browser.is_text_present('This field is required.')
137
138
    # Github check
139
    browser.visit(url)
140
    browser.fill('mobile', '1234567890')
141
    browser.select('interested_sections', section1.id)
142
    browser.select('interested_states', state1.id)
143
    browser.select('location', location1.id)
144
    browser.find_by_css('[type=submit]')[0].click()
145
    assert browser.is_text_present('Github or LinkedIn field is mandatory')
146
147
    browser.visit(url)
148
    browser.fill('mobile', '1234567890')
149
    browser.select('interested_sections', section1.id)
150
    browser.select('interested_states', state1.id)
151
    browser.select('location', location1.id)
152
    browser.fill('github', 'https://github.com')
153
    browser.find_by_css('[type=submit]')[0].click()
154
155
    assert browser.is_text_present(
156
        'Interested workshop level field is mandatory')
157
158
    browser.visit(url)
159
    browser.fill('mobile', '1234567890')
160
    browser.select('interested_sections', section1.id)
161
    browser.select('interested_states', state1.id)
162
    browser.select('interested_level', 1)
163
    browser.select('location', location1.id)
164
    browser.fill('github', 'https://github.com')
165
    browser.find_by_css('[type=submit]')[0].click()
166
    assert browser.is_text_present('This field is required.')
167
168
    browser.visit(url)
169
    browser.fill('first_name', 'First Name')
170
    browser.fill('last_name', 'Last Name')
171
    browser.fill('mobile', '1234567890')
172
    browser.select('interested_sections', section1.id)
173
    browser.select('interested_states', state1.id)
174
    browser.select('interested_level', 1)
175
    browser.select('location', location1.id)
176
    browser.fill('github', 'https://github.com')
177
    browser.fill('occupation', 'occupation')
178
    browser.fill('work_location', 'work_location')
179
    browser.fill('work_experience', 1)
180
181
    browser.find_by_css('[type=submit]')[0].click()
182
    assert browser.is_text_present('Deactive Account')
183
184
    org = f.create_organisation(location=location1)
185
    org.user.add(user)
186
    # section2 = f.create_workshop_section(name='section2')
187
188
    w1 = f.create_workshop(requester=org, workshop_section=section1)
189
    w1.presenter.add(user)
190
    w2 = f.create_workshop(requester=org, workshop_section=section1)
191
    w2.presenter.add(user)
192
    w3 = f.create_workshop(requester=org, workshop_section=section1)
193
    w3.presenter.add(user)
194
    w4 = f.create_workshop(requester=org, workshop_section=section1)
195
    w4.presenter.add(user)
196
    w5 = f.create_workshop(requester=org, workshop_section=section1)
197
    w5.presenter.add(user)
198
199
    url = base_url + '/profile/' + user.username + '/'
200
    browser.visit(url)
201
    # assert browser.is_text_present('Deactive Account')
202