def test_build_composer_environment_has_missing_key(self): os.environ['SOME_KEY'] = 'does not matter' ctx = utils.FormattedDict({ 'BUILD_DIR': '/usr/awesome', 'PHP_VM': 'php', 'TMPDIR': 'tmp', 'LIBDIR': 'lib', 'CACHE_DIR': 'cache', 'SOME_KEY': utils.wrap('{exact_match}') }) write_config_stub = Dingus() with patches({ 'composer.extension.PHPComposerStrategy.write_config': write_config_stub }): self.extension_module.ComposerExtension(ctx) cr = self.extension_module.ComposerCommandRunner(ctx, None) try: built_environment = cr._build_composer_environment() assert "{exact_match}" == built_environment['SOME_KEY'], \ "value should match" except KeyError, e: assert 'exact_match' != e.message, \ "Should not try to evaluate value [%s]" % e raise
def test_build_composer_environment_has_missing_key(self): os.environ['SOME_KEY'] = 'does not matter' ctx = utils.FormattedDict({ 'BP_DIR': '', 'BUILD_DIR': '/usr/awesome', 'WEBDIR': '', 'PHP_VM': 'php', 'TMPDIR': 'tmp', 'LIBDIR': 'lib', 'CACHE_DIR': 'cache', 'SOME_KEY': utils.wrap('{exact_match}') }) write_config_stub = Dingus() with patches({ 'composer.extension.PHPComposerStrategy.write_config': write_config_stub }): self.extension_module.ComposerExtension(ctx) cr = self.extension_module.ComposerCommandRunner(ctx, None) try: built_environment = cr._build_composer_environment() assert "{exact_match}" == built_environment['SOME_KEY'], \ "value should match" except KeyError, e: assert 'exact_match' != e.message, \ "Should not try to evaluate value [%s]" % e raise
def test_build_composer_environment_has_missing_key(self): os.environ["SOME_KEY"] = "does not matter" ctx = utils.FormattedDict( { "BUILD_DIR": "/usr/awesome", "WEBDIR": "", "PHP_VM": "php", "TMPDIR": "tmp", "LIBDIR": "lib", "CACHE_DIR": "cache", "SOME_KEY": utils.wrap("{exact_match}"), } ) write_config_stub = Dingus() with patches({"composer.extension.PHPComposerStrategy.write_config": write_config_stub}): self.extension_module.ComposerExtension(ctx) cr = self.extension_module.ComposerCommandRunner(ctx, None) try: built_environment = cr._build_composer_environment() assert "{exact_match}" == built_environment["SOME_KEY"], "value should match" except KeyError, e: assert "exact_match" != e.message, "Should not try to evaluate value [%s]" % e raise
def test_get_with_format_false(self): x = utils.FormattedDict({ 'DATA': utils.wrap('{some_key}') }) data = x.get('DATA', format=False) assert not hasattr(data, 'unwrap'), \ "should not be a wrapper object" assert "{some_key}" == data, "data should match"
def test_build_composer_environment_has_missing_key(self): os.environ['SOME_KEY'] = 'does not matter' ctx = utils.FormattedDict({ 'BUILD_DIR': '/usr/awesome', 'PHP_VM': 'php', 'TMPDIR': 'tmp', 'LIBDIR': 'lib', 'CACHE_DIR': 'cache', 'SOME_KEY': utils.wrap('{exact_match}') }) ct = self.extension_module.ComposerExtension(ctx) try: built_environment = ct._build_composer_environment() assert "{exact_match}" == built_environment['SOME_KEY'], \ "value should match" except KeyError, e: assert 'exact_match' != e.message, \ "Should not try to evaluate value [%s]" % e raise
def test_wrapped_object_to_string(self): x = utils.wrap('asdf') assert "asdf" == str(x), "wrong, got [%s]" % str(x) x = utils.wrap(utils.FormattedDict({})) assert "{}" == str(x), "wrong, got [%s]" % str(x)
def test_place_holder_wrapped(self): x = utils.FormattedDict({ 'DATA': utils.wrap('{some_key}') }) eq_('{some_key}', x['DATA'])
def test_json(self): x = utils.FormattedDict({ 'DATA': utils.wrap(json.dumps({'x': 1})) }) eq_('{"x": 1}', x['DATA'])