| Conditions | 9 |
| Total Lines | 77 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 | import re |
||
| 85 | def test_org_edit_flow(base_url, browser, outbox): |
||
| 86 | user = f.create_user() |
||
| 87 | user.set_password('123123') |
||
| 88 | user.save() |
||
| 89 | url = base_url + '/accounts/login/' |
||
| 90 | browser.visit(url) |
||
| 91 | browser.fill('login', user.email) |
||
| 92 | browser.fill('password', '123123') |
||
| 93 | browser.find_by_css('[type=submit]')[0].click() |
||
| 94 | assert len(outbox) == 1 |
||
| 95 | mail = outbox[0] |
||
| 96 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
| 97 | assert confirm_link |
||
| 98 | browser.visit(confirm_link[0]) |
||
| 99 | assert browser.title, "Confirm E-mail Address" |
||
| 100 | browser.find_by_css('[type=submit]')[0].click() |
||
| 101 | |||
| 102 | poc_type = f.create_usertype(slug='poc', display_name='poc') |
||
| 103 | user.profile.usertype.add(poc_type) |
||
| 104 | user.save() |
||
| 105 | |||
| 106 | location1 = f.create_locaiton(name='location1') |
||
| 107 | |||
| 108 | browser.fill('login', user.email) |
||
| 109 | browser.fill('password', '123123') |
||
| 110 | browser.find_by_css('[type=submit]')[0].click() |
||
| 111 | |||
| 112 | url = base_url + '/organisation/' |
||
| 113 | browser.visit(url) |
||
| 114 | org_create_link = browser.find_by_text('Add Organisation')[0] |
||
| 115 | assert org_create_link |
||
| 116 | org_create_link.click() |
||
| 117 | browser.select('organisation_type', 1) |
||
| 118 | browser.fill('name', 'Org2') |
||
| 119 | browser.fill('description', 'Description') |
||
| 120 | browser.select('location', location1.id) |
||
| 121 | browser.fill('organisation_role', 'Role1') |
||
| 122 | browser.find_by_css('[type=submit]')[0].click() |
||
| 123 | |||
| 124 | org = f.create_organisation(location=location1, created_by=user) |
||
| 125 | org.save() |
||
| 126 | |||
| 127 | user2 = f.create_user() |
||
| 128 | user2.set_password('123123') |
||
| 129 | user2.save() |
||
| 130 | |||
| 131 | # login |
||
| 132 | url = base_url + '/accounts/logout/' |
||
| 133 | browser.visit(url) |
||
| 134 | |||
| 135 | url = base_url + '/accounts/login/' |
||
| 136 | browser.visit(url) |
||
| 137 | browser.fill('login', user2.email) |
||
| 138 | browser.fill('password', '123123') |
||
| 139 | browser.find_by_css('[type=submit]')[0].click() |
||
| 140 | assert len(outbox) == 4 |
||
| 141 | mail = outbox[3] |
||
| 142 | confirm_link = re.findall(r'http.*/accounts/.*/', mail.body) |
||
| 143 | assert confirm_link |
||
| 144 | browser.visit(confirm_link[0]) |
||
| 145 | assert browser.title, "Confirm E-mail Address" |
||
| 146 | browser.find_by_css('[type=submit]')[0].click() |
||
| 147 | |||
| 148 | poc_type = f.create_usertype(slug='poc', display_name='poc') |
||
| 149 | user2.profile.usertype.add(poc_type) |
||
| 150 | user2.save() |
||
| 151 | |||
| 152 | org.user.add(user2) |
||
| 153 | org.save() |
||
| 154 | |||
| 155 | url = base_url + '/organisation/' |
||
| 156 | browser.fill('login', user2.email) |
||
| 157 | browser.fill('password', '123123') |
||
| 158 | browser.find_by_css('[type=submit]')[0].click() |
||
| 159 | browser.visit(url) |
||
| 160 | browser.find_by_text(org.name)[0].click() |
||
| 161 | assert not browser.find_by_text('Edit') |
||
| 162 |