| Conditions | 10 |
| Total Lines | 71 |
| 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:
Complex classes like test_signup_college_poc_flow() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | import re |
||
| 10 | def test_signup_college_poc_flow(base_url, browser, outbox): |
||
| 11 | f.create_usertype(slug='tutor', display_name='tutor') |
||
| 12 | user = f.create_user() |
||
| 13 | user.set_password('123123') |
||
| 14 | user.save() |
||
| 15 | url = base_url + '/workshop/' |
||
| 16 | browser.visit(url) |
||
| 17 | browser.fill('login', user.email) |
||
| 18 | browser.fill('password', '123123') |
||
| 19 | browser.find_by_css('[type=submit]')[0].click() |
||
| 20 | assert len(outbox) == 1 |
||
| 21 | mail = outbox[0] |
||
| 22 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
| 23 | assert confirm_link |
||
| 24 | browser.visit(confirm_link[0]) |
||
| 25 | assert browser.title, "Confirm E-mail Address" |
||
| 26 | browser.find_by_css('[type=submit]')[0].click() |
||
| 27 | |||
| 28 | assert "Login" in browser.title |
||
| 29 | |||
| 30 | browser.fill('login', user.email) |
||
| 31 | browser.fill('password', '123123') |
||
| 32 | browser.find_by_css('[type=submit]')[0].click() |
||
| 33 | |||
| 34 | assert browser.is_text_present("Dashboard") |
||
| 35 | |||
| 36 | poc_type = f.create_usertype(slug='poc', display_name='College POC') |
||
| 37 | user.profile.usertype.clear() |
||
| 38 | user.profile.usertype.add(poc_type) |
||
| 39 | user.profile.save() |
||
| 40 | user.save() |
||
| 41 | section1 = f.create_workshop_section(name='section1') |
||
| 42 | |||
| 43 | location1 = f.create_locaiton(name='location1') |
||
| 44 | state1 = f.create_state(name='state1') |
||
| 45 | |||
| 46 | # mobile number chechk |
||
| 47 | url = base_url + '/profile/' + user.username + '/edit' |
||
| 48 | browser.visit(url) |
||
| 49 | browser.fill('mobile', '') |
||
| 50 | browser.select('interested_sections', section1.id) |
||
| 51 | browser.select('location', location1.id) |
||
| 52 | browser.select('interested_states', state1.id) |
||
| 53 | browser.find_by_css('[type=submit]')[0].click() |
||
| 54 | assert browser.is_text_present('This field is required.') |
||
| 55 | |||
| 56 | # interested state check |
||
| 57 | browser.visit(url) |
||
| 58 | browser.fill('mobile', '1234567890') |
||
| 59 | browser.select('location', location1.id) |
||
| 60 | browser.select('interested_states', state1.id) |
||
| 61 | browser.find_by_css('[type=submit]')[0].click() |
||
| 62 | assert browser.is_text_present('This field is required.') |
||
| 63 | |||
| 64 | # location check |
||
| 65 | browser.visit(url) |
||
| 66 | browser.fill('mobile', '1234567890') |
||
| 67 | browser.select('interested_sections', section1.id) |
||
| 68 | browser.select('interested_states', state1.id) |
||
| 69 | browser.find_by_css('[type=submit]')[0].click() |
||
| 70 | assert browser.is_text_present('This field is required.') |
||
| 71 | |||
| 72 | browser.visit(url) |
||
| 73 | browser.fill('mobile', '1234567890') |
||
| 74 | browser.select('interested_sections', section1.id) |
||
| 75 | browser.select('interested_states', state1.id) |
||
| 76 | browser.select('location', location1.id) |
||
| 77 | # browser.fill('github', 'https://github.com') |
||
| 78 | browser.find_by_css('[type=submit]')[0].click() |
||
| 79 | |||
| 80 | assert browser.is_text_present('Deactive Account') |
||
| 81 | |||
| 176 |