def test_get_deployments_no_deployment(simple_yml_data): """Test that don't get anything if we don't have any deployments to get """ data = yaml_parser.read_yaml(simple_yml_data) deployments = yaml_parser.get_deployments(data) assert not deployments
def test_get_deployments(yml_with_deployments): """Test that we get two boxes for our two deployments """ data = yaml_parser.read_yaml(yml_with_deployments) deployments = yaml_parser.get_deployments(data) assert len(deployments) == 2
def test_get_no_metadata(yml_with_no_metadata): """Test that we get no exceptions if we have no "MetaData" in our yml """ data = yaml_parser.read_yaml(yml_with_no_metadata) deployments = yaml_parser.get_deployments(data) assert not deployments
def test_read_yaml_simple(simple_yml_data): """Check we can read a simple yml and get data """ data = yaml_parser.read_yaml(simple_yml_data) # Convert to a list assert len(data) == 1 assert data[0]["apiVersion"] == "v1" assert data[0]["kind"] == "Service"
def test_get_deployments_no_kind(yml_with_no_kind): """Test we get no exceptions (but also no deployments) if we don't have any "kind" in our yml """ data = yaml_parser.read_yaml(yml_with_no_kind) deployments = yaml_parser.get_deployments(data) assert not deployments
def process(input_file, output_file): """ Handle command line arguments for main command """ with open(input_file) as file: data = file.read() parsed_data = read_yaml(data) deployments = get_deployments(parsed_data) driver = OutputDriver(output_file) # for each deployment, draw a box with the name in it. # Draw each box and add 10 to each used x,y coordinate- check syntax to do this spacing = 200 for index, deployment in enumerate(deployments): deployment.box.x_pos = (1 + index) * spacing deployment.box.y_pos = 100 deployment.draw(driver) driver.output()
def test_empty_data(empty_data): """Test that we gracefully get an empty list of data if we feed an empty string to the function """ yaml_parser.read_yaml(empty_data)
def test_read_yaml(self): d = read_yaml('tests/data/yaml_test.yaml') self.assertTrue(set(d) == {'a', 'b', 'c'}) self.assertIsInstance(d['c'], list) self.assertListEqual(d.pop('c'), [1, 2]) self.assertDictEqual(d, {'a': 1, 'b': "00:00"})