Conditions | 8 |
Total Lines | 80 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | import re |
||
5 | def test_organisation_flow(base_url, browser, outbox): |
||
6 | f.create_usertype(slug='tutor', display_name='tutor') |
||
7 | user = f.create_user() |
||
8 | user.set_password('123123') |
||
9 | user.save() |
||
10 | url = base_url + '/accounts/login/' |
||
11 | browser.visit(url) |
||
12 | browser.fill('login', user.email) |
||
13 | browser.fill('password', '123123') |
||
14 | browser.find_by_css('[type=submit]')[0].click() |
||
15 | assert len(outbox) == 1 |
||
16 | mail = outbox[0] |
||
17 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
18 | assert confirm_link |
||
19 | browser.visit(confirm_link[0]) |
||
20 | assert browser.title, "Confirm E-mail Address" |
||
21 | browser.find_by_css('[type=submit]')[0].click() |
||
22 | location1 = f.create_locaiton(name='location1') |
||
23 | poc_type = f.create_usertype(slug='poc', display_name='poc') |
||
24 | user.profile.usertype.add(poc_type) |
||
25 | user.profile.location = location1 |
||
26 | user.profile.save() |
||
27 | user.save() |
||
28 | url = base_url + '/organisation/' |
||
29 | browser.fill('login', user.email) |
||
30 | browser.fill('password', '123123') |
||
31 | browser.find_by_css('[type=submit]')[0].click() |
||
32 | browser.visit(url) |
||
33 | org_create_link = browser.find_by_text('Add Organisation')[0] |
||
34 | assert org_create_link |
||
35 | org_create_link.click() |
||
36 | browser.select('organisation_type', 1) |
||
37 | browser.fill('name', 'Org1') |
||
38 | browser.fill('description', 'Description') |
||
39 | browser.select('location', location1.id) |
||
40 | browser.fill('organisation_role', 'Role1') |
||
41 | browser.find_by_css('[type=submit]')[0].click() |
||
42 | # browser.find_by_css('[clickable-row]')[0].click() |
||
43 | browser.find_by_text('Org1')[0].click() |
||
44 | |||
45 | browser.find_by_text('Edit')[0].click() |
||
46 | browser.fill('organisation_role', 'Role updated') |
||
47 | browser.find_by_css('[type=submit]')[0].click() |
||
48 | browser.find_by_text('Org1')[0].click() |
||
49 | browser.find_by_text('Delete')[0].click() |
||
50 | org = f.create_organisation(location=location1, created_by=user) |
||
51 | org.user.add(user) |
||
52 | org.save() |
||
53 | url = base_url + '/organisation/{}/edit/'.format(org.id) |
||
54 | browser.visit(url) |
||
55 | browser.fill('organisation_role', 'Role updated') |
||
56 | browser.find_by_css('[type=submit]')[0].click() |
||
57 | |||
58 | url = base_url + '/organisation/{}/'.format(org.id) |
||
59 | browser.visit(url) |
||
60 | delete_org_link = browser.find_by_text('Delete')[0] |
||
61 | assert delete_org_link |
||
62 | delete_org_link.click() |
||
63 | |||
64 | # for Exceptions |
||
65 | |||
66 | url = base_url + '/organisation/create/' |
||
67 | browser.visit(url) |
||
68 | browser.select('organisation_type', 1) |
||
69 | browser.fill('name', 'Org22') |
||
70 | browser.fill('description', 'Description22') |
||
71 | # browser.select('location', location1.id) |
||
72 | browser.fill('organisation_role', 'Role1') |
||
73 | browser.find_by_css('[type=submit]')[0].click() |
||
74 | assert browser.find_by_text('This field is required.')[0] |
||
75 | |||
76 | # user as regional lead |
||
77 | lead_type = f.create_usertype(slug='lead', display_name='lead') |
||
78 | user.profile.usertype.remove(poc_type) |
||
79 | user.profile.usertype.add(lead_type) |
||
80 | user.save() |
||
81 | url = base_url + '/organisation/' |
||
82 | browser.visit(url) |
||
83 | org_leadview_link = browser.find_by_text('My Organisations')[0] |
||
84 | assert org_leadview_link |
||
85 | |||
168 |