X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Ffrontend%2Fsamples%2Ftests.py;h=d85a46672ebc4e8902bce1a53fad6078b604ec34;hp=595727e13510c0eaa369e668056cef5c005b988d;hb=45bea53077b4e46618320beee76682d441e0a1c7;hpb=f22eb99f314ed48ceb0062dffe4f8f25c7cf09dd diff --git a/htsworkflow/frontend/samples/tests.py b/htsworkflow/frontend/samples/tests.py index 595727e..d85a466 100644 --- a/htsworkflow/frontend/samples/tests.py +++ b/htsworkflow/frontend/samples/tests.py @@ -18,6 +18,8 @@ from htsworkflow.frontend.samples.views import \ library_dict, \ library_json +from htsworkflow.frontend.auth import apidata + # The django test runner flushes the database between test suites not cases, # so to be more compatible with running via nose we flush the database tables # of interest before creating our sample data. @@ -123,9 +125,8 @@ class SampleWebTestCase(TestCase): for lib in Library.objects.all(): lib_dict = library_dict(lib.library_id) - self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') url = '/samples/library/%s/json' % (lib.library_id,) - lib_response = self.client.get(url) + lib_response = self.client.get(url, apidata) self.failUnlessEqual(lib_response.status_code, 200) lib_json = json.loads(lib_response.content) @@ -164,17 +165,15 @@ class SampleWebTestCase(TestCase): """ Make sure we get a 404 if we request an invalid library id """ - self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') - response = self.client.get('/samples/library/nottheone/json') + response = self.client.get('/samples/library/nottheone/json', apidata) self.failUnlessEqual(response.status_code, 404) - def test_library_not_logged_in(self): + def test_library_no_key(self): """ Make sure we get a 302 if we're not logged in """ response = self.client.get('/samples/library/10981/json') - self.failUnlessEqual(response.status_code, 302) - self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') - response = self.client.get('/samples/library/10981/json') + self.failUnlessEqual(response.status_code, 403) + response = self.client.get('/samples/library/10981/json', apidata) self.failUnlessEqual(response.status_code, 200)