def test_load_no_user_specefied_config_file(self): """ Test that not loading a user specefied config file works """ c = Core({}) c.load_user_specefied_config_file() assert c.config.get_tree() == {}
def test_load_no_user_specefied_config_file(self): """ Test that not loading a user specefied config file works """ c = Core({}) c.load_user_specefied_config_file() assert c.config.get_tree() == {}
def test_load_user_specefied_config_file_wrong_format(self, tmpdir): """ Config data is a dict at top level and loading something else should raise error """ f = tmpdir.join("empty.json") f.write('["foo", "bar"]') c = Core({"--config": str(f)}) with pytest.raises(Exception) as ex: c.load_user_specefied_config_file() assert str( ex.value).startswith("Data tree to merge must be of dict type")
def test_load_user_specefied_config_file(self, tmpdir): """ Test that loadinloading of config file that user specefies work and that config keys is set correctly. """ f = tmpdir.join("empty.json") f.write('{"foo": "bar"}') c = Core({"--config": str(f)}) c.load_user_specefied_config_file() assert c.config.get_tree() == {"foo": "bar"}
def test_load_user_specefied_config_file_wrong_format(self, tmpdir): """ Config data is a dict at top level and loading something else should raise error """ f = tmpdir.join("empty.json") f.write('["foo", "bar"]') c = Core({ "--config": str(f) }) with pytest.raises(Exception) as ex: c.load_user_specefied_config_file() assert str(ex.value).startswith("Data tree to merge must be of dict type")
def test_load_user_specefied_config_file(self, tmpdir): """ Test that loadinloading of config file that user specefies work and that config keys is set correctly. """ f = tmpdir.join("empty.json") f.write('{"foo": "bar"}') c = Core({ "--config": str(f) }) c.load_user_specefied_config_file() assert c.config.get_tree() == {"foo": "bar"}
def test_process_dockerfile(self, tmpdir): """ """ input = tmpdir.join("Dockerfile.jinja") input.write("{{ barfoo }}") o = tmpdir.join("Dockerfile") c = tmpdir.join("conf.json") c.write('{"env": {"barfoo": "foobar"}}') c = Core({ "--dockerfile": str(input), "--outfile": str(o), "--config": str(c), }) c.load_user_specefied_config_file() c.parse_env_vars() c.handle_data_sources() c.process_dockerfile() assert o.read() == "foobar"
def test_process_dockerfile(self, tmpdir): """ """ input = tmpdir.join("Dockerfile.jinja") input.write("{{ barfoo }}") o = tmpdir.join("Dockerfile") c = tmpdir.join("conf.json") c.write('{"env": {"barfoo": "foobar"}}') c = Core({ "--dockerfile": str(input), "--outfile": str(o), "--config": str(c), }) c.load_user_specefied_config_file() c.parse_env_vars() c.handle_data_sources() c.process_dockerfile() assert o.read() == "foobar"
def test_process_dockerfile_no_output_file_specefied(self, tmpdir): """ Found a bug that if no --outfile is specefied it will not work and throw exception that it should not do... """ input = tmpdir.join("Dockerfile.jinja") input.write("{{ barfoo }}") c = tmpdir.join("conf.json") c.write('{"env": {"barfoo": "foobar"}}') c = Core({ "--dockerfile": str(input), "--config": str(c), }) with pytest.raises(Exception) as ex: c.load_user_specefied_config_file() c.parse_env_vars() c.handle_data_sources() c.process_dockerfile() assert str(ex.value).startswith("missing key '--outfile' in cli_args. Could not write to output file.")
def test_process_dockerfile_no_output_file_specefied(self, tmpdir): """ Found a bug that if no --outfile is specefied it will not work and throw exception that it should not do... """ input = tmpdir.join("Dockerfile.jinja") input.write("{{ barfoo }}") c = tmpdir.join("conf.json") c.write('{"env": {"barfoo": "foobar"}}') c = Core({ "--dockerfile": str(input), "--config": str(c), }) with pytest.raises(Exception) as ex: c.load_user_specefied_config_file() c.parse_env_vars() c.handle_data_sources() c.process_dockerfile() assert str(ex.value).startswith( "missing key '--outfile' in cli_args. Could not write to output file." )