<s> import unittest <EOL> import os <EOL> from JustReleaseNotes . utils import EnvReplacer <EOL> from mock import MagicMock <EOL> from mock import Mock <EOL> class EnvParser_Test ( unittest . TestCase ) : <EOL> def test_listWithNoEnvStaysTheSame ( self ) : <EOL> conf = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> self . assertEqual ( conf , EnvReplacer . replace ( conf ) ) <EOL> def test_primitiveWithNoEnvStaysTheSame ( self ) : <EOL> conf = <NUM_LIT:1> <EOL> self . assertEqual ( conf , EnvReplacer . replace ( conf ) ) <EOL> def test_dictWithNoEnvStaysTheSame ( self ) : <EOL> conf = { <EOL> "<STR_LIT:a>" : "<STR_LIT>" , <EOL> "<STR_LIT:b>" : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT> , "<STR_LIT>" ] , <EOL> "<STR_LIT:c>" : { <EOL> "<STR_LIT:x>" : "<STR_LIT:y>" <EOL> } <EOL> } <EOL> self . assertEqual ( conf , EnvReplacer . replace ( conf ) ) <EOL> def test_stringWithNonExistentEnvVariableRaises ( self ) : <EOL> conf = "<STR_LIT>" <EOL> self . assertRaises ( KeyError , EnvReplacer . replace , conf ) <EOL> def test_stringWithEmptyEnvKeyStaysTheSame ( self ) : <EOL> conf = "<STR_LIT>" <EOL> self . assertEqual ( conf , EnvReplacer . replace ( conf ) ) <EOL> def test_stringWithInvalidEnvKeyStaysTheSame ( self ) : <EOL> conf = "<STR_LIT>" <EOL> self . assertEqual ( conf , EnvReplacer . replace ( conf ) ) <EOL> def test_stringWithMixedCaseEnvIsReplaced ( self ) : <EOL> os . environ [ "<STR_LIT:a>" ] = "<STR_LIT:1>" <EOL> os . environ [ "<STR_LIT:b>" ] = "<STR_LIT:2>" <EOL> os . environ [ "<STR_LIT:c>" ] = "<STR_LIT:3>" <EOL> conf = "<STR_LIT>" <EOL> self . assertEqual ( "<STR_LIT>" , EnvReplacer . replace ( conf ) ) <EOL> def test_dictWithEnvParsedCorrectly ( self ) : <EOL> os . environ [ '<STR_LIT:abc>' ] = '<STR_LIT>' <EOL> os . environ [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> os . environ [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> conf = { <EOL> "<STR_LIT:a>" : "<STR_LIT>" , <EOL> "<STR_LIT:b>" : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT> , "<STR_LIT>" ] , <EOL> "<STR_LIT:c>" : { <EOL> "<STR_LIT:x>" : "<STR_LIT>" , <EOL> "<STR_LIT:d>" : "<STR_LIT>" <EOL> } <EOL> } <EOL> expectedConf = { <EOL> "<STR_LIT:a>" : "<STR_LIT>" , <EOL> "<STR_LIT:b>" : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT> , "<STR_LIT>" ] , <EOL> "<STR_LIT:c>" : { <EOL> "<STR_LIT:x>" : "<STR_LIT>" , <EOL> "<STR_LIT:d>" : "<STR_LIT>" <EOL> } <EOL> } <EOL> self . assertEqual ( expectedConf , EnvReplacer . replace ( conf ) ) <EOL> def test_dictWithUnicodeEnvRaplacedCorrectly ( self ) : <EOL> os . environ [ '<STR_LIT:abc>' ] = '<STR_LIT>' <EOL> os . environ [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> os . environ [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> conf = { <EOL> u"<STR_LIT:a>" : "<STR_LIT>" , <EOL> "<STR_LIT:c>" : { <EOL> u"<STR_LIT:x>" : "<STR_LIT>" , <EOL> u"<STR_LIT:d>" : "<STR_LIT>" <EOL> } <EOL> } <EOL> expectedConf = { <EOL> u"<STR_LIT:a>" : "<STR_LIT>" , <EOL> "<STR_LIT:c>" : { <EOL> u"<STR_LIT:x>" : "<STR_LIT>" , <EOL> u"<STR_LIT:d>" : "<STR_LIT>" <EOL> } <EOL> } <EOL> self . assertEqual ( expectedConf , EnvReplacer . replace ( conf ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
