def test_create_magic_castle_init_fail(database_connection, monkeypatch): def fake_run(process_args, *args, **kwargs): if process_args == ["terraform", "init", "-no-color", "-input=false"]: raise CalledProcessError(1, "terraform init") monkeypatch.setattr("models.magic_castle.magic_castle.run", fake_run) cluster = MagicCastle(database_connection, "a-123-45.calculquebec.cloud") cluster.set_configuration(VALID_CLUSTER_CONFIGURATION) with pytest.raises( PlanException, match="An error occurred while initializing Terraform."): cluster.plan_creation()
def test_create_magic_castle_plan_export_fail(database_connection, monkeypatch): def fake_run(process_args, *args, **kwargs): if process_args[:4] == [ "terraform", "show", "-no-color", "-json", ]: raise CalledProcessError(1, "terraform show") monkeypatch.setattr("models.magic_castle.magic_castle.run", fake_run) cluster = MagicCastle(database_connection, "a-123-45.calculquebec.cloud") cluster.set_configuration(VALID_CLUSTER_CONFIGURATION) with pytest.raises( PlanException, match="An error occurred while exporting planned changes."): cluster.plan_creation()
def test_create_magic_castle_plan_valid(database_connection): cluster = MagicCastle(database_connection, "a-123-45.calculquebec.cloud") cluster.set_configuration(VALID_CLUSTER_CONFIGURATION) cluster.plan_creation()