Search in sources :

Example 6 with TestPythonGeneratedCode

use of com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method namedDetailedTapeList.

@Test
public void namedDetailedTapeList() throws TemplateModelException, IOException {
    final String modelDescriptorName = "NamedDetailedTapeList";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/namedDetailedTapeList.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElementList("Tape", "None", "NamedDetailedTape"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 7 with TestPythonGeneratedCode

use of com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method listMultiPartUploadApiBean.

@Test
public void listMultiPartUploadApiBean() throws TemplateModelException, IOException {
    final String modelDescriptorName = "ListMultiPartUploadsResult";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/listMultiPartUploadApiBean.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElement("Bucket", "None"), new TypeElement("Delimiter", "None"), new TypeElement("KeyMarker", "None"), new TypeElement("MaxUploads", "None"), new TypeElement("NextKeyMarker", "None"), new TypeElement("NextUploadIdMarker", "None"), new TypeElement("Prefix", "None"), new TypeElement("IsTruncated", "None"), new TypeElement("UploadIdMarker", "None"), new TypeElementList("CommonPrefixes", "None", "CommonPrefixes"), new TypeElementList("Upload", "None", "None"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeElement(com.spectralogic.ds3autogen.python.model.type.TypeElement) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 8 with TestPythonGeneratedCode

use of com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method simpleType.

@Test
public void simpleType() throws TemplateModelException, IOException {
    final String modelDescriptorName = "TestElementsType";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/simpleType.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeAttribute("InCache"), new TypeElement("MyBucket", "BucketDetails"), new TypeElement("ByteOffset", "None"), new TypeElementList("MyBucketList", "None", "BucketDetails"), new TypeElementList("Pool", "Pools", "None"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : TypeAttribute(com.spectralogic.ds3autogen.python.model.type.TypeAttribute) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeElement(com.spectralogic.ds3autogen.python.model.type.TypeElement) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 9 with TestPythonGeneratedCode

use of com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode in project ds3_autogen by SpectraLogic.

the class PythonFunctionalDocs_Test method getBucketRequest_Test.

@Test
public void getBucketRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetBucketRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    final Ds3DocSpec docSpec = new Ds3DocSpecImpl(ImmutableMap.of(requestName, "This is how you use the request"), ImmutableMap.of("Delimiter", "This is how you use delimiter", "Marker", "This is how you use marker", "MaxKeys", "This is how you use max keys", "Prefix", "This is how you use prefix", "BucketName", "This is how you use bucket name"));
    codeGenerator.generateCode(fileUtils, "/input/requests/getBucketRequest.xml", docSpec);
    //Test Request code
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final Pattern expectedConstructorDocs = Pattern.compile("'''\\s+" + "This is how you use the request\\s+" + "`bucket_name` This is how you use bucket name\\s+" + "`delimiter` This is how you use delimiter\\s+" + "`marker` This is how you use marker\\s+" + "`max_keys` This is how you use max keys\\s+" + "`prefix` This is how you use prefix\\s+" + "'''\\s+" + "def __init__\\(self, bucket_name, delimiter=None, marker=None, max_keys=None, prefix=None\\):", Pattern.MULTILINE | Pattern.UNIX_LINES);
    assertTrue(expectedConstructorDocs.matcher(ds3Code).find());
    //Test Client code
    final Pattern expectedCommandDoc = Pattern.compile("'''\\s+" + "This is how you use the request\\s+" + "'''\\s+" + "def get_bucket\\(self, request\\):", Pattern.MULTILINE | Pattern.UNIX_LINES);
    assertTrue(expectedCommandDoc.matcher(ds3Code).find());
}
Also used : Pattern(java.util.regex.Pattern) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Example 10 with TestPythonGeneratedCode

use of com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method bucketObjectsApiBean.

@Test
public void bucketObjectsApiBean() throws TemplateModelException, IOException {
    final String modelDescriptorName = "ListBucketResult";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/bucketObjectsApiBean.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElement("CreationDate", "None"), new TypeElement("Delimiter", "None"), new TypeElement("Marker", "None"), new TypeElement("MaxKeys", "None"), new TypeElement("Name", "None"), new TypeElement("NextMarker", "None"), new TypeElement("Prefix", "None"), new TypeElement("IsTruncated", "None"), new TypeElementList("CommonPrefixes", "None", "CommonPrefixes"), new TypeElementList("Contents", "None", "Contents"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeElement(com.spectralogic.ds3autogen.python.model.type.TypeElement) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)10 TestPythonGeneratedCode (com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode)10 Test (org.junit.Test)10 TypeContent (com.spectralogic.ds3autogen.python.model.type.TypeContent)5 TypeElementList (com.spectralogic.ds3autogen.python.model.type.TypeElementList)5 TypeElement (com.spectralogic.ds3autogen.python.model.type.TypeElement)3 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)1 Ds3DocSpecImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl)1 TypeAttribute (com.spectralogic.ds3autogen.python.model.type.TypeAttribute)1 Pattern (java.util.regex.Pattern)1