Conditions | 9 |
Total Lines | 99 |
Lines | 0 |
Ratio | 0 % |
Changes | 12 | ||
Bugs | 1 | Features | 1 |
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 | from datetime import datetime, timedelta |
||
8 | def test_workshop_flow(base_url, browser, outbox): |
||
9 | f.create_usertype(slug='tutor', display_name='tutor') |
||
10 | user = f.create_user() |
||
11 | user.set_password('123123') |
||
12 | user.save() |
||
13 | url = base_url + '/workshop/' |
||
14 | browser.visit(url) |
||
15 | browser.fill('login', user.email) |
||
16 | browser.fill('password', '123123') |
||
17 | browser.find_by_css('[type=submit]')[0].click() |
||
18 | assert len(outbox) == 1 |
||
19 | mail = outbox[0] |
||
20 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
21 | assert confirm_link |
||
22 | browser.visit(confirm_link[0]) |
||
23 | assert browser.title, "Confirm E-mail Address" |
||
24 | browser.find_by_css('[type=submit]')[0].click() |
||
25 | |||
26 | poc_type = f.create_usertype(slug='poc', display_name='poc') |
||
27 | user.profile.usertype.add(poc_type) |
||
28 | user.save() |
||
29 | org = f.create_organisation() |
||
30 | org.user.add(user) |
||
31 | user.profile.interested_locations.add(org.location) |
||
32 | user.profile.location = org.location |
||
33 | user.profile.save() |
||
34 | org.save() |
||
35 | |||
36 | workshop = f.create_workshop(requester=org) |
||
37 | |||
38 | workshop.expected_date = datetime.now() + timedelta(days=20) |
||
39 | # workshop.presenter.add(user) |
||
40 | workshop.status = WorkshopStatus.REQUESTED |
||
41 | workshop.location = org.location |
||
42 | workshop.save() |
||
43 | url = base_url + '/workshop/update/{}/'.format(workshop.id) |
||
44 | browser.visit(url) |
||
45 | browser.fill('login', user.email) |
||
46 | browser.fill('password', '123123') |
||
47 | browser.find_by_css('[type=submit]')[0].click() |
||
48 | tutor_type = f.create_usertype(slug='tutor', display_name='tutor') |
||
49 | user.profile.usertype.remove(poc_type) |
||
50 | user.profile.usertype.add(tutor_type) |
||
51 | user.save() |
||
52 | |||
53 | url = base_url + '/workshop/' |
||
54 | browser.visit(url) |
||
55 | |||
56 | accept_workshop_link = browser.find_by_text('Accept')[0] |
||
57 | assert accept_workshop_link |
||
58 | accept_workshop_link.click() |
||
59 | |||
60 | # reject_workshop_link = browser.find_by_text('Reject')[0] |
||
61 | # assert reject_workshop_link |
||
62 | # reject_workshop_link.click() |
||
63 | |||
64 | user.profile.usertype.remove(tutor_type) |
||
65 | user.profile.usertype.add(poc_type) |
||
66 | user.profile.save() |
||
67 | user.save() |
||
68 | |||
69 | # checking to move requested workshop in hold state |
||
70 | url = base_url + '/workshop/' |
||
71 | browser.visit(url) |
||
72 | hold_workshop_link = browser.find_by_text('Hold')[0] |
||
73 | assert hold_workshop_link |
||
74 | hold_workshop_link.click() |
||
75 | |||
76 | # checking to move on hold workshop into requested state |
||
77 | url = base_url + '/workshop/' |
||
78 | browser.visit(url) |
||
79 | publish_workshop_link = browser.find_by_text('Publish/Request')[0] |
||
80 | assert publish_workshop_link |
||
81 | publish_workshop_link.click() |
||
82 | hold_workshop_link = browser.find_by_text('Hold')[0] |
||
83 | assert hold_workshop_link |
||
84 | |||
85 | # checking declined state |
||
86 | decline_workshop_link = browser.find_by_text('Decline')[0] |
||
87 | decline_workshop_link.click() |
||
88 | workshop.status = WorkshopStatus.REQUESTED |
||
89 | workshop.save() |
||
90 | |||
91 | workshop.expected_date = datetime.now() + timedelta(days=-20) |
||
92 | workshop.save() |
||
93 | |||
94 | url = base_url + '/workshop/' |
||
95 | browser.visit(url) |
||
96 | |||
97 | f.create_workshop_rating() |
||
98 | publish_workshop_link = browser.find_by_text('Share Feedback')[0] |
||
99 | assert publish_workshop_link |
||
100 | publish_workshop_link.click() |
||
101 | url = base_url + '/workshop/feedback/{}'.format(workshop.id) |
||
102 | browser.visit(url) |
||
103 | browser.check('rating0-1') |
||
104 | browser.fill('comment', "Testing comments") |
||
105 | |||
106 | browser.find_by_css('[type=submit]')[0].click() |
||
107 |