[WIP][python-exp] Force camelization of imports (#7186)

* [python-exp] Force camelization of imports

* Add unit test
This commit is contained in:
TIm Clark
2020-08-11 17:11:07 -04:00
committed by GitHub
parent b48112d941
commit f609120236
2 changed files with 9 additions and 1 deletions

View File

@@ -330,7 +330,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
@Override
public String toModelImport(String name) {
// name looks like Cat
return "from " + modelPackage() + "." + toModelFilename(name) + " import "+ name;
return "from " + modelPackage() + "." + toModelFilename(name) + " import "+ toModelName(name);
}
@Override

View File

@@ -333,4 +333,12 @@ public class PythonClientExperimentalTest {
Assert.assertEquals(defaultValue, "dateutil_parser('2010-01-01T10:10:10.000111+01:00')");
}
@Test(description = "format imports of models containing special characters")
public void importSpecialModelNameTest() {
final PythonClientExperimentalCodegen codegen = new PythonClientExperimentalCodegen();
String importValue = codegen.toModelImport("special.ModelName");
Assert.assertEquals(importValue, "from models.special_model_name import SpecialModelName");
}
}