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