def test_add_dict(): c = k8s.Context() c += {'apiVersion': 'v1', 'containers': [{'name': 'bob'}]} assert c._render_data() == [{ 'apiVersion': 'v1', 'containers': [{ 'name': 'bob' }] }]
def test_create_output_dir(fixtures_dir): output_dir = fixtures_dir / 'generator_data' / 'simple' / 'does_not_exist' output_file = output_dir / 'output.yaml' shutil.rmtree(str(output_dir), ignore_errors=True) c = k8s.Context(output=output_file) c += k8s.Service(dict(foo=42)) c.render() assert output_file.exists()
def test_add_auto_data(): c = k8s.Context() s = cfg.AutoData() s.apiVersion = 'v1' s.metadata.name = 'foobar' c += s assert c._render_data() == [{ 'apiVersion': 'v1', 'metadata': { 'name': 'foobar' } }]
def test_add_data_to_context(): c = k8s.Context() c += k8s.Data(dict(foo="bar")) assert [{'foo': 'bar'}] == c._render_data()
def test_can_not_add_to_context(): c = k8s.Context() with pytest.raises(Exception): c += k8s.Service