Skip to content

Commit ce4d334

Browse files
committed
fix tests
1 parent cd4f66e commit ce4d334

File tree

2 files changed

+58
-31
lines changed

2 files changed

+58
-31
lines changed

qiita_pet/handlers/study_handlers/listing_handlers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def get(self, ignore):
194194
return
195195
except:
196196
# catch any other error as generic server error
197+
self.clear()
197198
self.set_status(500)
198199
self.write("Server error during search. Please try again "
199200
"later")

qiita_pet/test/test_study_handlers.py

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,6 @@ def setUp(self):
1818
'num_samples_collected shared '
1919
'num_raw_data pi pmids owner status '
2020
'abstract')
21-
self.exp_studies = {
22-
self.StudyTuple(
23-
id=1,
24-
title='Identification of the Microbiomes for Cannabis Soils',
25-
meta_complete=True, num_samples_collected=27,
26-
shared='<a target="_blank" href="mailto:shared@foo.bar">'
27-
'Shared</a>',
28-
num_raw_data=4,
29-
pi='<a target="_blank" href="mailto:PI_dude@foo.bar">'
30-
'PIDude</a>',
31-
pmids='<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
32-
'pubmed/123456">123456</a>, '
33-
'<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
34-
'pubmed/7891011">7891011</a>',
35-
owner='<a target="_blank" href="mailto:test@foo.bar">'
36-
'test@foo.bar</a>',
37-
status='public',
38-
abstract='This is a preliminary study to examine the '
39-
'microbiota associated with the Cannabis plant. Soils samples '
40-
'from the bulk soil, soil associated with the roots, and the '
41-
'rhizosphere were extracted and the DNA sequenced. Roots from '
42-
'three independent plants of different strains were examined. '
43-
'These roots were obtained November 11, 2011 from plants that '
44-
'had been harvested in the summer. Future studies will '
45-
'attempt to analyze the soils and rhizospheres from the same '
46-
'location at different time points in the plant lifecycle.')}
4721
super(TestHelpers, self).setUp()
4822

4923
def test_get_shared_links_for_study(self):
@@ -52,11 +26,39 @@ def test_get_shared_links_for_study(self):
5226
self.assertEqual(obs, exp)
5327

5428
def test_build_study_info(self):
29+
self.maxDiff = None
5530
Study(1).status = 'public'
5631
obs = _build_study_info('standard', User('test@foo.bar'))
57-
self.assertItemsEqual(obs, self.exp_studies)
32+
exp = {self.StudyTuple(
33+
id=1,
34+
title='Identification of the Microbiomes for Cannabis Soils',
35+
meta_complete=True, num_samples_collected=27,
36+
shared='<a target="_blank" href="mailto:shared@foo.bar">'
37+
'Shared</a>',
38+
num_raw_data=4,
39+
pi='<a target="_blank" href="mailto:PI_dude@foo.bar">'
40+
'PIDude</a>',
41+
pmids='<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
42+
'pubmed/123456">123456</a>, '
43+
'<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
44+
'pubmed/7891011">7891011</a>',
45+
owner='<a target="_blank" href="mailto:test@foo.bar">'
46+
'test@foo.bar</a>',
47+
status='public',
48+
abstract='This is a preliminary study to examine the '
49+
'microbiota associated with the Cannabis plant. Soils samples '
50+
'from the bulk soil, soil associated with the roots, and the '
51+
'rhizosphere were extracted and the DNA sequenced. Roots from '
52+
'three independent plants of different strains were examined. '
53+
'These roots were obtained November 11, 2011 from plants that '
54+
'had been harvested in the summer. Future studies will '
55+
'attempt to analyze the soils and rhizospheres from the same '
56+
'location at different time points in the plant lifecycle.')}
57+
self.assertItemsEqual(obs, exp)
5858

5959
def test_build_study_info_new_study(self):
60+
self.maxDiff = None
61+
Study(1).status = 'public'
6062
info = {
6163
'timeseries_type_id': 1,
6264
'portal_type_id': 1,
@@ -70,17 +72,41 @@ def test_build_study_info_new_study(self):
7072
user = User('test@foo.bar')
7173

7274
Study.create(user, 'test_study_1', efo=[1], info=info)
73-
7475
obs = _build_study_info('standard', user)
75-
self.exp_studies.add(
76+
exp = {
77+
self.StudyTuple(
78+
id=1,
79+
title='Identification of the Microbiomes for Cannabis Soils',
80+
meta_complete=True, num_samples_collected=27,
81+
shared='<a target="_blank" href="mailto:shared@foo.bar">'
82+
'Shared</a>',
83+
num_raw_data=4,
84+
pi='<a target="_blank" href="mailto:PI_dude@foo.bar">'
85+
'PIDude</a>',
86+
pmids='<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
87+
'pubmed/7891011">7891011</a>, '
88+
'<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
89+
'pubmed/123456">123456</a>',
90+
owner='<a target="_blank" href="mailto:test@foo.bar">'
91+
'test@foo.bar</a>',
92+
status='public',
93+
abstract='This is a preliminary study to examine the '
94+
'microbiota associated with the Cannabis plant. Soils samples '
95+
'from the bulk soil, soil associated with the roots, and the '
96+
'rhizosphere were extracted and the DNA sequenced. Roots from '
97+
'three independent plants of different strains were examined. '
98+
'These roots were obtained November 11, 2011 from plants that '
99+
'had been harvested in the summer. Future studies will '
100+
'attempt to analyze the soils and rhizospheres from the same '
101+
'location at different time points in the plant lifecycle.'),
76102
self.StudyTuple(
77103
id=2, title='test_study_1', meta_complete=False,
78104
num_samples_collected=None, shared='', num_raw_data=0,
79105
pi='<a target="_blank" href="mailto:PI_dude@foo.bar">'
80106
'PIDude</a>', pmids='', owner='<a target="_blank" '
81107
'href="mailto:test@foo.bar">test@foo.bar</a>',
82-
status='sandbox', abstract='abstract'))
83-
self.assertItemsEqual(obs, self.exp_studies)
108+
status='sandbox', abstract='abstract')}
109+
self.assertItemsEqual(obs, exp)
84110

85111

86112
class TestStudyEditorForm(TestHandlerBase):

0 commit comments

Comments
 (0)