Skip to content

Commit

Permalink
Merge pull request #256 from tableau/johng42-patch-4
Browse files Browse the repository at this point in the history
add test to validate info response with auth off
  • Loading branch information
0golovatyi committed Apr 16, 2019
2 parents 1dfa9d5 + 0744f76 commit 26ab5ab
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tabpy-server/server_tests/test_service_info_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,64 @@ def test_given_tabpy_server_with_auth_expect_correct_info_response(self):
'required': True,
}
}, features)


class TestServiceInfoHandlerWithoutAuth(AsyncHTTPTestCase):
@classmethod
def setUpClass(cls):
prefix = '__TestServiceInfoHandlerWithoutAuth_'

# create state.ini dir and file
cls.state_dir = tempfile.mkdtemp(prefix=prefix)
with open(os.path.join(cls.state_dir, 'state.ini'), 'w+')\
as cls.state_file:
cls.state_file.write('[Service Info]\n'
'Name = TabPy Serve\n'
'Description = \n'
'Creation Time = 0\n'
'Access-Control-Allow-Origin = \n'
'Access-Control-Allow-Headers = \n'
'Access-Control-Allow-Methods = \n'
'\n'
'[Query Objects Service Versions]\n'
'\n'
'[Query Objects Docstrings]\n'
'\n'
'[Meta]\n'
'Revision Number = 1\n')
cls.state_file.close()

# create config file
cls.config_file = tempfile.NamedTemporaryFile(
prefix=prefix, suffix='.conf', delete=False, mode='w+')
cls.config_file.write(
'[TabPy]\n'
'TABPY_STATE_PATH = {}'.format(
cls.state_dir))
cls.config_file.close()

@classmethod
def tearDownClass(cls):
os.remove(cls.state_file.name)
os.remove(cls.config_file.name)
os.rmdir(cls.state_dir)

def get_app(self):
self.app = TabPyApp(self.config_file.name)
return self.app._create_tornado_web_app()

def test_tabpy_server_with_no_auth_expect_correct_info_response(self):
response = self.fetch('/info')
self.assertEqual(response.code, 200)
actual_response = json.loads(response.body)
expected_response = _create_expected_info_response(
self.app.settings, self.app.tabpy_state)

self.assertDictEqual(actual_response, expected_response)
self.assertTrue('versions' in actual_response)
versions = actual_response['versions']
self.assertTrue('v1' in versions)
v1 = versions['v1']
self.assertTrue('features' in v1)
features = v1['features']
self.assertDictEqual({}, features)

0 comments on commit 26ab5ab

Please sign in to comment.