From 2ab49dc6f4cf5501424f4d250941f2e70e8c19cf Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 7 Nov 2016 10:05:05 -0700 Subject: [PATCH 1/2] fix #1975 --- .../handlers/study_handlers/edit_handlers.py | 2 ++ .../tests/test_edit_handlers.py | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/qiita_pet/handlers/study_handlers/edit_handlers.py b/qiita_pet/handlers/study_handlers/edit_handlers.py index 8d83a1f73..d438796e2 100644 --- a/qiita_pet/handlers/study_handlers/edit_handlers.py +++ b/qiita_pet/handlers/study_handlers/edit_handlers.py @@ -289,6 +289,8 @@ def post(self, study=None): dois = dois[0].split(',') # Make sure that we strip the spaces from the pubmed ids the_study.publications = [(doi.strip(), None) for doi in dois] + elif the_study.publications != '': + the_study.publications = [] self.render('index.html', message=msg, level='success') diff --git a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py index efe389966..57ed863f7 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py @@ -107,6 +107,31 @@ def test_post_edit(self): self.assertTrue(check_count('qiita.study', study_count_before)) self.assertEqual(study.title, 'New title - test post edit') + def test_post_edit_blank_doi(self): + study_count_before = get_count('qiita.study') + study = Study(1) + study_info = study.info + + post_data = { + 'new_people_names': [], + 'new_people_emails': [], + 'new_people_affiliations': [], + 'new_people_addresses': [], + 'new_people_phones': [], + 'study_title': 'New title - test post edit', + 'study_alias': study_info['study_alias'], + 'publications_doi': '', + 'study_abstract': study_info['study_abstract'], + 'study_description': study_info['study_description'], + 'principal_investigator': study_info['principal_investigator'].id, + 'lab_person': study_info['lab_person'].id} + + self.post('/study/edit/1', post_data) + + # Check that the study was updated + self.assertTrue(check_count('qiita.study', study_count_before)) + self.assertEqual(study.title, 'New title - test post edit') + self.assertEqual(study.publications, []) class TestCreateStudyAJAX(TestHandlerBase): def test_get(self): From ba2de84ea0bdcfb74878fbd48e87a3c0983a8729 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 7 Nov 2016 10:20:06 -0700 Subject: [PATCH 2/2] fix flake8 --- qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py index 57ed863f7..0caa9d345 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py @@ -133,6 +133,7 @@ def test_post_edit_blank_doi(self): self.assertEqual(study.title, 'New title - test post edit') self.assertEqual(study.publications, []) + class TestCreateStudyAJAX(TestHandlerBase): def test_get(self): response = self.get('/check_study/', {'study_title': 'notreal'})