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:"));
}
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():"));
}
Aggregations