def main(argv=sys.argv): SQLITE_FILE = "%s/.d2c_test/d2c_db.sqlite" % os.path.expanduser('~') if os.path.exists(SQLITE_FILE): print "Deleting existing DB" os.unlink(SQLITE_FILE) dao = DAO(SQLITE_FILE) test_initor.init_db(dao, argv[1]) app = Application(dao, AMIToolsFactory()) app.MainLoop()
def main(argv=sys.argv): conf = argv[1] sqlFile = "%s/.d2c_test/main_test_stub.sqlite" % os.path.expanduser('~') if os.path.exists(sqlFile): print "Deleting existing DB" os.unlink(sqlFile) mockBoto = mock(boto) def mock_connect_ec2(*args, **kwargs): return DummyConn() mockBoto.connect_ec2 = mock_connect_ec2 mockRemoteFactory = mock(RemoteShellExecutorFactory) when(mockRemoteFactory).executor(any(), any(), any(), any(), any()).thenReturn(mock(RemoteShellExecutor)) when(mockRemoteFactory).executor(any(), any(), any()).thenReturn(mock(RemoteShellExecutor)) mockExecFactory = mock(ShellExecutorFactory) when(mockExecFactory).executor(any(), any()).thenReturn(mock(ShellExecutor)) dao = DAO(sqlFile, mockBoto, mockRemoteFactory, mockExecFactory) test_initor.init_db(dao, conf) mockAMIFactory = mock(AMIToolsFactory) mockAMITools = mock(AMITools) when(mockAMIFactory).getAMITools(any()).thenReturn(mockAMITools) when(mockAMITools).getArch(any()).thenReturn("x86_64") when(mockAMITools).registerAMI(any(), any(), any()).thenReturn("foobarami") print dao.getAMIs() app = Application(dao, mockAMIFactory) app.MainLoop()
import sys import os from d2c.Application import Application from d2c.data.DAO import DAO from d2c.AMITools import AMIToolsFactory import test_initor SQLITE_FILE = "%s/.d2c_test/d2c_db.sqlite" % os.path.expanduser('~') if os.path.exists(SQLITE_FILE): print "Deleting existing DB" os.unlink(SQLITE_FILE) dao = DAO(SQLITE_FILE) test_initor.init_db(dao, "/home/willmore/scicloud.conf") deployment = dao.getDeployments()[0] deployment.state = "FOOBAR" uploadAction = deployment.roles[0].uploadActions[0] uploadAction.logger = True dao.saveDeployment(deployment) assert uploadAction.logger assert uploadAction is deployment.roles[0].uploadActions[0]