From cde1294048822ae4e5e030eb05ef10eca890aff3 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Sat, 29 Apr 2017 13:15:09 -0600 Subject: [PATCH] fix #2069 - adding tests --- .../tests/test_listing_handlers.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py index 314efbb92..3e952b534 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py @@ -84,9 +84,37 @@ def setUp(self): self.exp = [self.single_exp] def test_build_study_info(self): + for a in Study(1).artifacts(): + a.visibility='private' + + obs = _build_study_info(User('test@foo.bar'), 'user') + self.assertEqual(obs, self.exp) + + obs = _build_study_info(User('test@foo.bar'), 'public') + self.assertEqual(obs, []) + + obs = _build_study_info(User('demo@microbio.me'), 'public') + self.assertEqual(obs, []) + + # make all the artifacts public - (1) the only study in the tests, + for a in Study(1).artifacts(): + a.visibility='public' + self.exp[0]['status'] = 'public' + obs = _build_study_info(User('test@foo.bar'), 'user') self.assertEqual(obs, self.exp) + obs = _build_study_info(User('test@foo.bar'), 'public') + self.assertEqual(obs, []) + + obs = _build_study_info(User('demo@microbio.me'), 'public') + self.assertEqual(obs, self.exp) + + # return to it's private status + for a in Study(1).artifacts(): + a.visibility='private' + + def test_build_study_info_erros(self): with self.assertRaises(IncompetentQiitaDeveloperError): _build_study_info(User('test@foo.bar'), 'user', study_proc={})