def test_config_field_get_3T(): ''' Tests retrieving field from a section in the config file. ''' resp = config_interface.get_endpoint('Handle_FieldConfig').direct_get( 'double key', 'rest config test') assert resp == 'atlas horses'
def test_config_field_get_4F(): ''' Tests retrieving field from a section in the config file. ''' resp = config_interface.get_endpoint('Handle_FieldConfig').direct_get( 'not_a_key', 'bad_section') assert resp == 'Can\'t find field: not_a_key in section: bad_section'
def test_config_field_get_2(): ''' Tests retrieving field from a section in the config file. ''' resp = config_interface.get_endpoint('Handle_FieldConfig').direct_get( 'key2', 'rest config test') assert resp == 'theseus'
def test_config_full_get(): h = hashlib.new('sha256') ''' Tests retrieving the entire config file. ''' resp = config_interface.get_endpoint('Handle_FullConfig').direct_get() h.update(resp.encode('utf-8'))
def test_config_section_get_OK(): ''' Tests retrieving a section in the config file. ''' resp = config_interface.get_endpoint( 'Handle_SectionConfig').direct_get('rest config test') assert json.dumps( resp) == '[["key1", "trident"], ["key2", "theseus"], ["double key", "atlas horses"]]'
def test_config_section_get_FAIL(): resp = config_interface.get_endpoint('Handle_SectionConfig').direct_get( 'not_a_section') assert resp == 'Failed to find section: not_a_section'
Created on 28 June 2016 @author: dgrossman, lanhamt """ import logging import falcon import pytest from poseidon.poseidonMonitor.Config.Config import config_interface module_logger = logging.getLogger(__name__) application = falcon.API() application.add_route('/v1/config', config_interface.get_endpoint('Handle_FullConfig')) application.add_route('/v1/config/{section}', config_interface.get_endpoint('Handle_SectionConfig')) application.add_route('/v1/config/{section}/{field}', config_interface.get_endpoint('Handle_FieldConfig')) # exposes the application for testing @pytest.fixture def app(): return application def test_config_full_get(client): """ Tests retrieving the entire config file.