Conditions | 4 |
Total Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 | from datetime import datetime, timedelta |
||
9 | def test_workshop_wrong_action(base_url, browser, outbox): |
||
10 | tutor_type = f.create_usertype(slug='tutor', display_name='tutor') |
||
11 | poc_type = f.create_usertype(slug='poc', display_name='poc') |
||
12 | |||
13 | user = f.create_user() |
||
14 | user.set_password('123123') |
||
15 | user.save() |
||
16 | url = base_url + '/workshop/' |
||
17 | browser.visit(url) |
||
18 | browser.fill('login', user.email) |
||
19 | browser.fill('password', '123123') |
||
20 | browser.find_by_css('[type=submit]')[0].click() |
||
21 | assert len(outbox) == 1 |
||
22 | mail = outbox[0] |
||
23 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
24 | assert confirm_link |
||
25 | browser.visit(confirm_link[0]) |
||
26 | assert browser.title, "Confirm E-mail Address" |
||
27 | browser.find_by_css('[type=submit]')[0].click() |
||
28 | |||
29 | user.profile.usertype.clear() |
||
30 | user.profile.usertype.add(poc_type) |
||
31 | user.save() |
||
32 | org = f.create_organisation() |
||
33 | org.user.add(user) |
||
34 | user.profile.interested_locations.add(org.location) |
||
35 | user.profile.location = org.location |
||
36 | user.profile.save() |
||
37 | org.save() |
||
38 | |||
39 | workshop = f.create_workshop(requester=org) |
||
40 | |||
41 | workshop.expected_date = datetime.now() + timedelta(days=20) |
||
42 | workshop.status = WorkshopStatus.REQUESTED |
||
43 | workshop.location = org.location |
||
44 | workshop.save() |
||
45 | url = base_url + '/workshop/update/{}/'.format(workshop.id) |
||
46 | browser.visit(url) |
||
47 | browser.fill('login', user.email) |
||
48 | browser.fill('password', '123123') |
||
49 | browser.find_by_css('[type=submit]')[0].click() |
||
50 | |||
51 | section1 = f.create_workshop_section(name='section1') |
||
52 | location = org.location |
||
53 | state = f.create_state(name='state2') |
||
54 | |||
55 | user.profile.usertype.clear() |
||
56 | user.profile.usertype.add(tutor_type) |
||
57 | |||
58 | user.profile.location = location |
||
59 | user.profile.interested_states.add(state) |
||
60 | user.profile.mobile = '1234567890' |
||
61 | user.profile.interested_sections.add(section1) |
||
62 | user.profile.interested_level = 1 |
||
63 | user.profile.github = 'https://github.com' |
||
64 | user.profile.save() |
||
65 | user.save() |
||
66 | |||
67 | url = base_url + '/workshop/'+'feedback/000/' |
||
68 | browser.visit(url) |
||
69 | |||
70 | url = base_url + '/workshop/feedback/{}/'.format(workshop.id) |
||
71 | browser.visit(url) |
||
72 | |||
191 |