Skip to content

Fix 1293 #2291

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

Merged
merged 6 commits into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix errors
  • Loading branch information
antgonza committed Sep 18, 2017
commit 74baa1adb18c29f1f2aa7e7b70c59c42610ca876
39 changes: 4 additions & 35 deletions qiita_pet/handlers/api_proxy/tests/test_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_study_get_req(self):
exp = {
'status': 'success',
'study_info': {
'mixs_compliant': True, 'metadata_complete': True,
'reprocess': False, 'owner': 'test@foo.bar',
'mixs_compliant': True, 'metadata_complete': True, 'level': '',
'reprocess': False, 'owner': 'test@foo.bar', 'message': '',
'emp_person_id': 2, 'number_samples_promised': 27,
'funding': None, 'show_biom_download_button': True,
'publication_pid': ['123456', '7891011'], 'vamps_id': None,
Expand Down Expand Up @@ -341,37 +341,6 @@ def test_study_prep_get_req_no_access(self):
'message': 'User does not have access to study'}
self.assertEqual(obs, exp)

def test_study_delete_req(self):
info = {
"timeseries_type_id": 1,
"metadata_complete": True,
"mixs_compliant": True,
"number_samples_collected": 25,
"number_samples_promised": 28,
"study_alias": "FCM",
"study_description": "DESC",
"study_abstract": "ABS",
"emp_person_id": qdb.study.StudyPerson(2),
"principal_investigator_id": qdb.study.StudyPerson(3),
"lab_person_id": qdb.study.StudyPerson(1)
}

new_study = qdb.study.Study.create(
qdb.user.User('test@foo.bar'), "Some New Study to delete", info)

study_delete_req(new_study.id, 'test@foo.bar')

with self.assertRaises(qdb.exceptions.QiitaDBUnknownIDError):
qdb.study.Study(new_study.id)

def test_study_delete_req_error(self):
obs = study_delete_req(1, 'test@foo.bar')
exp = {'status': 'error',
'message': 'Unable to delete study: Study "Identification of '
'the Microbiomes for Cannabis Soils" cannot be '
'erased because it has a sample template'}
self.assertEqual(obs, exp)

def test_study_delete_req_no_access(self):
obs = study_delete_req(1, 'demo@microbio.me')
exp = {'status': 'error',
Expand Down Expand Up @@ -525,7 +494,7 @@ def test_study_get_tags_request(self):
self.assertEqual(obs, exp)

# check error
obs = study_get_tags_request('shared@foo.bar', 2)
obs = study_get_tags_request('shared@foo.bar', 2000)
exp = {'message': 'Study does not exist', 'status': 'error'}
self.assertEqual(obs, exp)

Expand Down Expand Up @@ -560,7 +529,7 @@ def test_study_tags_patch_request(self):
self.assertEqual(obs, exp)

obs = study_tags_patch_request(
'shared@foo.bar', 2, 'replace', '/tags', ['testA', 'testB'])
'shared@foo.bar', 2000, 'replace', '/tags', ['testA', 'testB'])
exp = {'message': 'Study does not exist', 'status': 'error'}
self.assertEqual(obs, exp)

Expand Down
12 changes: 0 additions & 12 deletions qiita_pet/handlers/study_handlers/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from unittest import main
from json import loads

from qiita_pet.test.tornado_test_base import TestHandlerBase
from qiita_db.handlers.tests.oauthbase import OauthTestingBase
Expand All @@ -27,17 +26,6 @@ class StudyBaseInfoAJAX(TestHandlerBase):
pass


class StudyDeleteAjaxTests(TestHandlerBase):
def test_delete_study(self):
response = self.post('/study/delete/', {'study_id': 1})
self.assertEqual(response.code, 200)
exp = {'status': 'error',
'message': 'Unable to delete study: Study "Identification of '
'the Microbiomes for Cannabis Soils" cannot be '
'erased because it has a sample template'}
self.assertEqual(loads(response.body), exp)


class DataTypesMenuAJAXTests(TestHandlerBase):
def test_get(self):
response = self.get('/study/description/data_type_menu/',
Expand Down
24 changes: 13 additions & 11 deletions qiita_ware/test/test_private_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@
from qiita_ware.private_plugin import private_task


class BaseTestPrivatePlugin(TestCase):
def _create_job(self, cmd_name, values_dict):
user = User('test@foo.bar')
qiita_plugin = Software.from_name_and_version('Qiita', 'alpha')
cmd = qiita_plugin.get_command(cmd_name)
params = Parameters.load(cmd, values_dict=values_dict)
job = ProcessingJob.create(user, params)
job._set_status('queued')
return job


@qiita_test_checker()
class TestPrivatePlugin(TestCase):
class TestPrivatePlugin(BaseTestPrivatePlugin):
def setUp(self):
fd, self.fp = mkstemp(suffix=".txt")
close(fd)
Expand All @@ -50,15 +61,6 @@ def tearDown(self):

r_client.flushdb()

def _create_job(self, cmd_name, values_dict):
user = User('test@foo.bar')
qiita_plugin = Software.from_name_and_version('Qiita', 'alpha')
cmd = qiita_plugin.get_command(cmd_name)
params = Parameters.load(cmd, values_dict=values_dict)
job = ProcessingJob.create(user, params)
job._set_status('queued')
return job

def test_copy_artifact(self):
# Failure test
job = self._create_job('copy_artifact',
Expand Down Expand Up @@ -377,7 +379,7 @@ def test_complete_job(self):


@qiita_test_checker()
class TestPrivatePluginDeleteStudy(TestPrivatePlugin):
class TestPrivatePluginDeleteStudy(BaseTestPrivatePlugin):
def test_delete_study(self):
# as samples have been submitted to EBI, this will fail
job = self._create_job('delete_study', {'study': 1})
Expand Down