Search in sources :

Example 1 with TestPython3GeneratedCode

use of com.spectralogic.ds3autogen.python3.utils.TestPython3GeneratedCode in project ds3_autogen by SpectraLogic.

the class Python3FunctionalTests method simpleRequest.

@Test
public void simpleRequest() throws IOException, TemplateModelException {
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPython3GeneratedCode codeGenerator = new TestPython3GeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/simpleRequest.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    assertThat(ds3Code, is(notNullValue()));
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    //test template imports from python 2 module
    assertTrue(ds3Code.contains("def createClientFromEnv():"));
    //test imports
    assertTrue(ds3Code.contains("from .ds3network import *"));
    assertFalse(ds3Code.contains("from ds3network import *"));
    //test abstract request
    assertTrue(ds3Code.contains("class AbstractRequest(object, metaclass=ABCMeta):"));
    assertFalse(ds3Code.contains("class AbstractRequest(object):"));
    //test abstract response
    assertTrue(ds3Code.contains("class AbstractResponse(object, metaclass=ABCMeta):"));
    assertFalse(ds3Code.contains("class AbstractResponse(object):"));
    assertTrue(ds3Code.contains("if header[0].lower() == key.lower():"));
    assertFalse(ds3Code.contains("if header[0] == key:"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestPython3GeneratedCode(com.spectralogic.ds3autogen.python3.utils.TestPython3GeneratedCode) Test(org.junit.Test)

Example 2 with TestPython3GeneratedCode

use of com.spectralogic.ds3autogen.python3.utils.TestPython3GeneratedCode in project ds3_autogen by SpectraLogic.

the class Python3FunctionalTests method putObjectRequestTest.

@Test
public void putObjectRequestTest() throws IOException, TemplateModelException {
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPython3GeneratedCode codeGenerator = new TestPython3GeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/putObject.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    assertThat(ds3Code, is(notNullValue()));
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    assertTrue(ds3Code.contains("for key, val in headers.items():"));
    assertFalse(ds3Code.contains("for key, val in headers.iteritems():"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestPython3GeneratedCode(com.spectralogic.ds3autogen.python3.utils.TestPython3GeneratedCode) Test(org.junit.Test)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)2 TestPython3GeneratedCode (com.spectralogic.ds3autogen.python3.utils.TestPython3GeneratedCode)2 Test (org.junit.Test)2