def test_extract_instance_types(): test_cases = [ { # minimum accepted behavior, on demand instance type from typical Senza "input": {"InstanceType": "foo"}, "given_config": {}, "expected_config": {"compute": {"instanceTypes": {"ondemand": "foo", "spot": ["foo"]}}}, }, { # both on demand instance type from typical Senza and spot alternatives specified "input": {"InstanceType": "foo", "SpotAlternatives": ["bar", "baz"]}, "given_config": {}, "expected_config": {"compute": {"instanceTypes": {"ondemand": "foo", "spot": ["bar", "baz"]}}}, }, ] for test_case in test_cases: got = test_case["given_config"] extract_instance_types(test_case["input"], got) assert test_case["expected_config"] == got
def test_missing_instance_type(): with pytest.raises(click.UsageError): extract_instance_types({}, {}) with pytest.raises(click.UsageError): extract_instance_types({"SpotAlternatives": ["foo", "bar", "baz"]}, {})