<s> import os <EOL> import sys <EOL> import unittest2 as unittest <EOL> from os . path import join as pjoin <EOL> from raxcli . config import get_config , DEFAULT_ENV_PREFIX <EOL> FIXTURES_DIR = pjoin ( os . path . dirname ( os . path . abspath ( __file__ ) ) , '<STR_LIT>' ) <EOL> class TestConfigParsing ( unittest . TestCase ) : <EOL> def test_config_from_file_global_section_1 ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> config = get_config ( app = None , config_path = path1 ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_config_from_file_global_section_2 ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> config = get_config ( app = None , config_path = path1 ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_from_file_global_with_app_section_precedence ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> config = get_config ( app = '<STR_LIT>' , config_path = path1 ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_config_from_file_only_app_section ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> config = get_config ( app = '<STR_LIT>' , config_path = path1 ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , True ) <EOL> def test_config_from_file_default_values ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> default_values = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' } <EOL> config = get_config ( app = '<STR_LIT>' , config_path = path1 , <EOL> default_values = default_values ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_config_from_file_default_values_and_env ( self ) : <EOL> path1 = os . path . join ( FIXTURES_DIR , '<STR_LIT>' ) <EOL> default_values = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' } <EOL> env_dict = { } <EOL> env_dict [ DEFAULT_ENV_PREFIX + '<STR_LIT>' ] = '<STR_LIT>' <EOL> env_dict [ DEFAULT_ENV_PREFIX + '<STR_LIT>' ] = '<STR_LIT:false>' <EOL> config = get_config ( app = '<STR_LIT>' , config_path = path1 , <EOL> default_values = default_values , env_dict = env_dict ) <EOL> self . assertEqual ( config [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( config [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
