-
Notifications
You must be signed in to change notification settings - Fork 79
add sample validation page for wetlab #3213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cdba252
b3210c6
48d2e6a
aa1352a
db1d266
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| {% extends sitebase.html %} | ||
| {% block head %} | ||
| <style> | ||
| .column { | ||
| float: left; | ||
| width: 25%; | ||
| } | ||
|
|
||
| .row:after { | ||
| content: ""; | ||
| display: table; | ||
| clear: both; | ||
| } | ||
| </style> | ||
| {% end %} | ||
| {% block content %} | ||
| <h1>Sample Validation</h1><br> | ||
| {% if input %} | ||
| <form action="{% raw qiita_config.portal_dir %}/admin/sample_validation/" method="post" id="sample_validation_form"> | ||
| <label for="qid">Qiita id:</label><br> | ||
| <input type="text" id="qid" name="qid"><br> | ||
| <label for="snames">Sample names:</label><br> | ||
| <textarea id="sname" name="snames"></textarea><br><br> | ||
| <input type="submit" value="Submit"> | ||
| </form> | ||
| {% else %} | ||
| <div class="row"> | ||
| <div class="column"> | ||
| <h2>Matching</h2> | ||
| <ul> | ||
| {% for sample in matching %} | ||
| <li>{{ sample }}</li> | ||
| {% end %} | ||
| </ul> | ||
| </div> | ||
| <div class="column"> | ||
| <h2>Missing</h2> | ||
| <ul> | ||
| {% for sample in missing %} | ||
| <li>{{ sample }}</li> | ||
| {% end %} | ||
| </ul> | ||
| </div> | ||
| <div class="column"> | ||
| <h2>Blank</h2> | ||
| <ul> | ||
| {% for sample in blank %} | ||
| <li>{{ sample }}</li> | ||
| {% end %} | ||
| </ul> | ||
| </div> | ||
| <div class="column"> | ||
| <h2>Extra</h2> | ||
| <ul> | ||
| {% for sample in extra %} | ||
| <li>{{ sample }}</li> | ||
| {% end %} | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| <form action="{% raw qiita_config.portal_dir %}/admin/sample_validation/" method="get" id="return_to_sample_validation_form"> | ||
| <input type="submit" value="Validate more samples"> | ||
| </form> | ||
| {% end %} | ||
| {% end %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,5 +45,31 @@ def test_get_missing_argument(self): | |
| response.body.decode('ascii')) | ||
|
|
||
|
|
||
| class TestSampleValidation(BaseAdminTests): | ||
| def test_get(self): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned during the meeting, a good unittest should canvas the common things that might break your method/function. For example, calling post without one or both of the post_args, or giving a value for qid or snames that is obviously bad. This confirms that error-handling exists and is working properly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified unit test to also check error handling of post with invalid qid |
||
| response = self.get('/admin/sample_validation/') | ||
| self.assertEqual(response.code, 200) | ||
|
|
||
| def test_post(self): | ||
| # Check success | ||
| post_args = { | ||
| 'qid': 1, | ||
| 'snames': 'SKB1.640202 SKB2.640194 BLANK.1A BLANK.1B' | ||
| } | ||
| response = self.post('/admin/sample_validation/', post_args) | ||
| self.assertEqual(response.code, 200) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some coders will return 200 as long as the command executed without failure on the server-side. It's good to check the response.text and confirm it does not contain error messages and contains at least some string of text you're expecting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified unit test to check that the response body contains the inputted sample names |
||
| snames = ['SKB1.640202', 'SKB2.640194', 'BLANK.1A', 'BLANK.1B'] | ||
| body = response.body.decode('ascii') | ||
| for name in snames: | ||
| self.assertIn(name, body) | ||
| # Check failure: invalid qiita id | ||
| post_args = { | ||
| 'qid': 2, | ||
| 'snames': 'SKB1.640202 SKB2.640194 BLANK.1A BLANK.1B' | ||
| } | ||
| response = self.post('/admin/sample_validation/', post_args) | ||
| self.assertEqual(response.code, 500) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Uh oh!
There was an error while loading. Please reload this page.