class LogServiceDaoTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(LogServiceDaoTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def createWell(self, mdstart, mdstop, wellName): logger.debug(">>createWell() ") session = DM.getSession() well = Well() well.name = wellName well.depth_reference = "MDKB" well.elevation_of_depth_reference = "24.0" well.mdstart = mdstart well.mdstop = mdstop session.add(well) session.commit() dummyWell = session.query(Well).filter(Well.name == wellName).one() assert wellName == dummyWell.name session.close() return dummyWell def test_getAllLogServicesForWell(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3VariableDepthLogs(well.id) logServices = LogServiceDao.getAllLogServicesForWell(well.id)
def test_findLogWithLargestDepthRange(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup = DummyDbSetup() self.dummyDbSetup.setupDatabase() session = DM.getSession() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3VariableDepthLogs(well.id) log = Log() longestLog = log.findLogWithLargestDepthRange(logs) self.assertEqual("3SP", longestLog.name)
class WellPlotDefaultsInitializerTest(unittest.TestCase): def __init__(self, *args, **kwargs): logger.debug(">>__init__()") super(WellPlotDefaultsInitializerTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def test___initialiseWellPlotDefaults(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() #WellPlotTemplateInitialiser is run in db setup so don't need to re-run it here wellPlotPrefs = WellPlotDataDao.getWellPlotPreferences() logger.debug("uid: {0} well_id: {1}".format(wellPlotPrefs.uid, wellPlotPrefs.well_id))
class LogTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(LogTest, self).__init__(*args, **kwargs) def test_findLogWithLargestDepthRange(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup = DummyDbSetup() self.dummyDbSetup.setupDatabase() session = DM.getSession() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3VariableDepthLogs(well.id) log = Log() longestLog = log.findLogWithLargestDepthRange(logs) self.assertEqual("3SP", longestLog.name)
class DomainTrackWidgetTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(DomainTrackWidgetTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() self.app = QApplication(sys.argv) def getWellPLotdata(self): self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3Logs(well.id) wellPlotModelAccess = WellPlotModelAccess() uid = 42 templateDao = WellPlotTemplateDao() allTemplates = templateDao.getAllWellPlotTemplates() template = None for item in allTemplates: if item.uid == WellPlotType.ALLLOGS.uid: template = item wellPlotData = wellPlotModelAccess.createWellPlotData( logs, uid, well, template) return wellPlotData def test_generateDomainPlot(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create1Log(well.id) track = QWidget() track.setFixedWidth(180) wellPlotData = self.getWellPLotdata() self.assertIsNotNone(wellPlotData, "wellPlotData is None") domainStart, domainStop, domainStep = WellPlotUtils.calculateStartStopStep( wellPlotData.getLogTrackDatas()) plots = [] i = 0 for domainTrackData in wellPlotData.getZAxisDatas(): if i == 0: domainTrackWidget = DomainTrackWidget( well, isPrimaryDomainTrack=True) else: domainTrackWidget = DomainTrackWidget( well, isPrimaryDomainTrack=False) domainTrackWidget.generateDomainPlot(domainTrackData, wellPlotData, domainStart, domainStop, domainStep) plots.append(domainTrackWidget) self.assertEqual(1, len(plots), "length incorrect")
class WellPlotUtilsTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(WellPlotUtilsTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def getWellPlotdata(self): self.dummyDbSetup.setupDatabase() templates = WellPlotTemplateDao.getAllWellPlotTemplates() assert 9 == len(templates), "Incorrect template number: {0}".format(len(templates)) templates = WellPlotTemplateDao.getAllWellPlotTemplates() well = self.dummyDbSetup.createWell() self.dummyDbSetup.create1Log(well.id) logs = LogDao.getWellLogs(well.id) wellPlotModelAccess = WellPlotModelAccess() uid = 42 templateDao = WellPlotTemplateDao() #allTemplates = templateDao.getAllWellPlotTemplates() template = templateDao.getWellPlotTemplateFromUid("alllogs") #template = allTemplates[0] template.__init__() wellPlotData = wellPlotModelAccess.createWellPlotData(logs, uid, well, template) return wellPlotData def test_calculateStartStopStep(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) wellPlotData = self.getWellPlotdata() self.assertIsNotNone(wellPlotData, "Is None") start, stop, step = WellPlotUtils.calculateStartStopStep(wellPlotData.getLogTrackDatas()) logger.debug("--test_calculateStartStopStep() start:{0} stop:{1} step:{2}".format(start, stop, step))
class WellPlotModelTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(WellPlotModelTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def test_createWellPlotData(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3Logs(well.id) templateDao = WellPlotTemplateDao() logger.debug( "--test_createWellPlotData() created WellPlotTemplateDao()") allTemplaes = templateDao.getAllWellPlotTemplates() logger.debug( "--test_createWellPlotData() created templateDao.getAllWellPlotTemplates() len:{0}" .format(len(allTemplaes))) template = allTemplaes[0] #need to run as properties are called inside init() method template.__init__() logger.debug("uid: {0}, name: {1}".format(template.uid, template.name)) uid = 42 wellPlotModelAccess = WellPlotModelAccess() logger.debug( "--test_createWellPlotData() created WellPlotModelAccess() template[0].name:{0}" .format(template.name)) wellPlotData = wellPlotModelAccess.createWellPlotData( logs, uid, well, template) logger.debug( "--test_createWellPlotData() created wellPlotModelAccess.createWellPlotData()" ) self.assertEquals(uid, wellPlotData.uid) logger.debug("TODO test all other properties")
class HeaderViewerTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(HeaderViewerTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def getWellPLotdata(self): self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3Logs(well.id) wellPlotModelAccess = WellPlotModelAccess() uid = 42 templateDao = WellPlotTemplateDao() allTemplates = templateDao.getAllWellPlotTemplates() template = None for item in allTemplates: if item.uid == WellPlotType.ALLLOGS.uid: template = item wellPlotData = wellPlotModelAccess.createWellPlotData(logs, uid, well, template) return wellPlotData def test_LogHeaderLabel(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create1Log(well.id) track = QWidget() track.setFixedWidth(180) wellPlotData = self.getWellPLotdata() self.assertIsNotNone(wellPlotData, "Is None") logHeaderLabel = LogHeaderLabel(logs[0], track, wellPlotData) boundWidth = logHeaderLabel.logName_label.fontMetrics().boundingRect(logHeaderLabel.logName_label.text()).width() self.assertEquals(track.geometry().width(), logHeaderLabel.geometry().width()) self.assertEquals("SWIRR", logHeaderLabel.logName_label.text()) logger.debug("--test_LogHeaderLabel() name bound width:{0} name width:{1}".format(boundWidth, logHeaderLabel.logName_label.geometry().width() )) logger.debug("--test_LogHeaderLabel() Lval x:{0} name x:{1} Rval x:{2}".format(logHeaderLabel.logValLeft_label.geometry().x(), logHeaderLabel.logName_label.geometry().x(), logHeaderLabel.logValRight_label.geometry().x() )) summedWidth = logHeaderLabel.logValLeft_label.geometry().width()+ logHeaderLabel.logName_label.geometry().width()+logHeaderLabel.logValRight_label.geometry().width() logger.debug("--test_LogHeaderLabel()summed width:{0}".format(summedWidth))
class WellPlotSettingsDialogTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(WellPlotSettingsDialogTest, self).__init__(*args, **kwargs) #QWidget: Must construct a QApplication before a QPaintDevice #self.app = QApplication(sys.argv) self.dummyDbSetup = DummyDbSetup() def test_tickDisplayedLogs(self): #test that all input logs are automatically checked in the table logger.debug( "=================================================================" ) logger.debug(">>test_tickDisplayedLogs() ") app = QApplication(sys.argv) well, logPlotData = self.generateLogPlotData() layoutDialog = WellPlotSettingsDialog(logPlotData, well) rows = layoutDialog.chkboxTableWidget.rowCount() cols = layoutDialog.chkboxTableWidget.columnCount() logs = LogDao.getWellLogsOptSession(well, logSet=None) self.assertEquals(3, len(logs)) #number of logs=3 + Log name column plus extra column self.assertEquals(5, cols) chkBoxItem = layoutDialog.chkboxTableWidget.item(0, 0) self.assertIsNotNone(chkBoxItem) plotList = layoutDialog._wellPlotData.sub_plots self.assertEquals(3, len(plotList)) for row, log in enumerate(logs): for subPlotData in plotList: for plotLog in subPlotData.getLogs(): if log.id == plotLog.id: logger.debug( "--test_tickDisplayedLogs() match found id: {0}". format(log.id)) chkState = layoutDialog.chkboxTableWidget.item( row, subPlotData.plot_index).checkState() self.assertEquals(QtCore.Qt.Checked, chkState) logger.debug( "=================================================================" ) def test_changeLogTrack(self): #test that on column removal all indexes are set correctly logger.debug( "=================================================================" ) logger.debug(">>test_changeLogTrack() ") app = QApplication(sys.argv) well, logPlotData = self.generateLogPlotData() layoutDialog = WellPlotSettingsDialog(logPlotData, well) plotLogs = self.getCurrentlyPlottedLogs(logPlotData) self.assertEquals(3, len(plotLogs)) subPlotList = layoutDialog._wellPlotData.sub_plots self.assertEquals(1, subPlotList[0].plot_index) self.assertEquals(2, subPlotList[1].plot_index) self.assertEquals(3, subPlotList[2].plot_index) self.assertEquals("LWD_GR", subPlotList[0]._logs[0].name) self.assertEquals("2DT", subPlotList[1]._logs[0].name) self.assertEquals("3SP", subPlotList[2]._logs[0].name) self.assertEquals(3, len(subPlotList)) chkBoxItem = layoutDialog.chkboxTableWidget.item(0, 1) logger.debug("--test_changeLogTrack() unchecking first cell") chkBoxItem.setCheckState(QtCore.Qt.Unchecked) subPlotList = layoutDialog._wellPlotData.sub_plots self.assertEquals(-1, subPlotList[0].plot_index) #log has been removed self.assertEquals(0, len(subPlotList[0]._logs)) self.assertEquals("2DT", subPlotList[1]._logs[0].name) self.assertEquals("3SP", subPlotList[2]._logs[0].name) self.assertEquals(1, subPlotList[1].plot_index) self.assertEquals(2, subPlotList[2].plot_index) self.assertEquals(3, len(subPlotList)) logger.debug( "=================================================================" ) def test_removeEmptyColumns(self): #test that on column removal all indexes are set correctly logger.debug( "=================================================================" ) logger.debug(">>test_removeEmptyColumns() ") app = QApplication(sys.argv) well, logPlotData = self.generateLogPlotData() layoutDialog = WellPlotSettingsDialog(logPlotData, well) plotLogs = self.getCurrentlyPlottedLogs(logPlotData) self.assertEquals(3, len(plotLogs)) logs = LogDao.getLogNamesCSV(plotLogs) logger.debug("--test_removeEmptyColumns() initial logs: " + logs) allRows = layoutDialog.chkboxTableWidget.rowCount() allColumns = layoutDialog.chkboxTableWidget.columnCount() self.assertEquals(3, allRows) self.assertEquals(5, allColumns) #unselect first log chkBoxItem = layoutDialog.chkboxTableWidget.item(0, 1) log = chkBoxItem.data(Qt.UserRole) logger.debug( "--test_removeEmptyColumns() unchecking first cell log name: " + str(log.name)) chkBoxItem.setCheckState(QtCore.Qt.Unchecked) newPlotLogs = self.getCurrentlyPlottedLogs(logPlotData) newLogs = LogDao.getLogNamesCSV(newPlotLogs) self.assertEquals("2DT,3SP", newLogs) self.getCheckbxTableStatus(layoutDialog) allRows = layoutDialog.chkboxTableWidget.rowCount() allColumns = layoutDialog.chkboxTableWidget.columnCount() self.assertEquals(3, allRows) self.assertEquals(4, allColumns) chkBoxItem = layoutDialog.chkboxTableWidget.item(1, 1) log = chkBoxItem.data(Qt.UserRole) logger.debug( "--test_removeEmptyColumns() unchecking second cell log name: " + str(log.name)) #unselect another log chkBoxItem.setCheckState(QtCore.Qt.Unchecked) newPlotLogs = self.getCurrentlyPlottedLogs(logPlotData) newLogs = LogDao.getLogNamesCSV(newPlotLogs) allRows = layoutDialog.chkboxTableWidget.rowCount() allColumns = layoutDialog.chkboxTableWidget.columnCount() self.assertEquals(3, allRows) self.assertEquals(3, allColumns) self.assertEquals("3SP", newLogs) self.getCheckbxTableStatus(layoutDialog) plotList = logPlotData.sub_plots #self.assertEquals(2, len(plotList)) firstPlot = plotList[0] firstPlotLogs = [] for log in firstPlot.getLogs(): firstPlotLogs.append(log) #self.assertEquals(1, len(firstPlotLogs)) #self.assertEquals("2DT", firstPlotLogs[0].name) secondPlot = plotList[1] secondPlotLogs = [] for log in secondPlot.getLogs(): secondPlotLogs.append(log) #self.assertEquals(1, len(secondPlotLogs)) #self.assertEquals("3PEF", secondPlotLogs[1].name) logger.debug( "=================================================================" ) def getCheckbxTableStatus(self, layoutDialog): allRows = layoutDialog.chkboxTableWidget.rowCount() allColumns = layoutDialog.chkboxTableWidget.columnCount() #start at one so don't include the name column #end at number columns-1 as last one will be unchecked for column in range(1, allColumns - 1): checked = False for row in range(allRows): tw = layoutDialog.chkboxTableWidget.item(row, column) if tw != None: if (tw != None) and (tw.checkState() == QtCore.Qt.Checked): checked = True logger.debug( "--getCheckbxTableStatus() row: {0}, col: {1} checked, text {2}" .format(row, column, tw.text)) if not checked: logger.debug( "--getCheckbxTableStatus() no logs checked in col: " + str(column)) def getCurrentlyPlottedLogs(self, logPlotData): plotLogs = [] plotList = logPlotData.sub_plots for subPlotData in plotList: for log in subPlotData.getLogs(): plotLogs.append(log) return plotLogs def generateLogPlotData(self): ''' using wellplot method to create data - preferred way may want to put data creation outside wellplot? ''' logger.debug(">>test_generateLogPlotData() ") self.dummyDbSetup.setupDatabase() #QWidget: Must construct a QApplication before a QPaintDevice #app = QApplication(sys.argv) well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3Logs(well.id) wellPlot = WellPlotPG(logs, well) logPlotData = wellPlot.createWellPlotData(logs) plotList = logPlotData.sub_plots self.assertEquals(3, len(plotList)) return well, logPlotData ''' def test_getTickedLogs(self): logger.debug(">>test_getTickedLogs() ") self.setupDatabase() #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) well = self.createWell() logs = self.createLogs(well.id) wellPlot = WellPlotMPL(logs, well) plotList = wellPlot.generateSubPlotDatas(logs) logPlotData = self.createWellPlotData() logPlotData.logList = logs logPlotData.sub_plots = plotList mockLayoutLogic = LogDao() mockLayoutLogic.getWellLogs = MagicMock(return_value = logs) layoutDialog = WellPlotSettingsDialog(logPlotData, well) logger.debug("--test_getTickedLogs() WellPlotSettingsDialog created") rows = layoutDialog.chkboxTableWidget.rowCount() cols = layoutDialog.chkboxTableWidget.columnCount() logger.debug("--test_getTickedLogs() rows: "+str(rows)+" cols: "+str(cols)) logs = LogDao.getWellLogsOptSession(well, logSet=None) self.assertEquals(3, len(logs)) #number of logs=3 + Log name column plus extra column self.assertEquals(5, cols) chkBoxItem = layoutDialog.chkboxTableWidget.item(0,0) self.assertIsNotNone(chkBoxItem) plotList = layoutDialog._wellPlotData.sub_plots self.assertEquals(3, len(plotList)) for subPlotData in plotList: for plotLog in subPlotData.getLogs(): logger.debug("test_getTickedLogs() log name: {0} plot index:{1}".format(plotLog.name, subPlotData.plot_index)) self.assertEquals(True, WidgetUtils.getBoolFromQtCheck(chkBoxItem.checkState())) chkBoxItem.setCheckState(QtCore.Qt.Unchecked) logger.debug("--------------------------------------") #layoutDialog.chkboxTableWidget.item(1, 1).setCheckState(QtCore.Qt.Checked) ''' ''' def test_logData(self): logger.debug(">>test_logData() ") self.setupDatabase() #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) well = self.createWell() logs = self.createLogs(well.id) for log in logs: logger.debug("--test_logData() log name: {0} type: {1} id: {2}".format(log.name, log.log_type, log.id)) units = LogDao.getUnits(log) logger.debug("--test_logData() units: {0} ".format(units)) logger.debug("--------------------------------------") ''' '''
def __init__(self, *args, **kwargs): super(LogServiceDaoTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup()
def __init__(self, *args, **kwargs): super(LasPersisterTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup()
class LasPersisterTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(LasPersisterTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() @patch('sqlalchemy.orm.session.Session') def test_writeLogData(self, mock_class): logger.debug(">>test_writeLogData()") #self.dummyDbSetup = DummyDbSetup() self.dummyDbSetup.setupDatabase() session = DM.getSession() well = self.dummyDbSetup.createWell(session) logs = self.dummyDbSetup.create3Logs(well.id, session) data = BaseDao.convertJSONtoData(logs[0].log_data_str) logData = np.empty((len(logs), len(data))) for i, log in enumerate(logs): data = BaseDao.convertJSONtoData(log.log_data_str) for j, sample in enumerate(data): logData[i][j] = sample log.importLog = True dataTest = logData[1,:] lasPersister = LasPersister(session) lasReader = LasReader() lasReader.logList = logs lasReader._logs = logData lasPersister._logSetId = 1 lasPersister._logServiceId = 1 #TODO log domain needs to be created with dumy DB logDomain = LogDomainDao.getLogDomain(log.log_domain_id, session) lasPersister._logDomainId = logDomain.id lasReader.logDomain = logDomain lasPersister._lasReader = lasReader lasPersister._wellId = well.id lasPersister._lasModel = lasReader.lasModel lasRounding = 4 lasPersister._lasImportLogicModel = LasImportLogicModel() lasPersister.writeLogData(lasPersister._lasModel, lasPersister._lasImportLogicModel, lasRounding) allLogs = session.query(Log).all() for log in allLogs: logger.debug("--test_writeLogData() post write log data id:{0}, name:{1}".format(log.id, log.name)) session.close() @patch('sqlalchemy.orm.session.Session') def test_updateWellStartStop(self, mock_class): logger.debug(">>test_updateWellStartStop()") #self.dummyDbSetup = DummyDbSetup() self.dummyDbSetup.setupDatabase() session = DM.getSession() well = self.dummyDbSetup.createWell(session) logs = self.dummyDbSetup.create3Logs(well.id, session) data = BaseDao.convertJSONtoData(logs[0].log_data_str) logData = np.empty((len(logs), len(data))) domainId = 0 for i, log in enumerate(logs): if i == 0: domainId = log.log_domain_id data = BaseDao.convertJSONtoData(log.log_data_str) for j, sample in enumerate(data): logData[i][j] = sample log.importLog = True dataTest = logData[1,:] lasPersister = LasPersister(session) lasReader = LasReader() lasReader.logList = logs lasReader._logs = logData lasPersister._logSetId = 1 lasPersister._logServiceId = 1 #TODO log domain needs to be created with dumy DB logDomain = LogDomainDao.getLogDomain( domainId, session) self.assertNotEqual(None, logDomain, "Sould not be None") lasPersister._logDomainId = logDomain.id lasReader.logDomain = logDomain logger.debug("well.mdstart:{0}, well.mdstop:{1}, logDomain.log_start:{2}, logDomain.log_stop:{3}".format(well.mdstart, well.mdstop, logDomain.log_start, logDomain.log_stop)) lasPersister._lasReader = lasReader lasPersister._wellId = well.id lasPersister.writeLogData() allLogs = session.query(Log).all() for log in allLogs: logger.debug("--test_updateWellStartStop() post write log data id:{0}, name:{1}".format(log.id, log.name)) session.close() @patch('sqlalchemy.orm.session.Session') def test_computeStepNp(self, mock_class): logger.debug(">>test_computeStepNp()") lasPersister = LasPersister(mock_class) data = [] #constant = 0.1524 for i in range(1000): if (i % 2 == 0): data.append(i-0.000001) else: data.append(i+0.000001) data.append(2.34) lasPersister.computeStepNp(data, 1.0, 4) logger.debug("consistent step: "+str(lasPersister._consistentStep)) logger.debug("meanStepValue: "+str(lasPersister._meanStepValue)) logger.debug("stepIndexes len: "+str(len(lasPersister._stepIndexes))) logger.debug("steps len: "+str(len(lasPersister._uniqueSteps))) @patch('sqlalchemy.orm.session.Session') def test_getRounding(self, mock_class): lasPersister = LasPersister(mock_class) rounding = lasPersister.getRounding(0.1524) logger.debug(" rounding: "+str(rounding)) @patch('sqlalchemy.orm.session.Session') def test_calcSteppedDepth(self, mock_class): lasPersister = LasPersister(mock_class) data = [] logDomain = LogDomain() logDomain.log_start = 1746.5088 logDomain.log_stop = 2707.7904 logDomain.log_step = 0.1524 depth_data = lasPersister.calcSteppedDepth(logDomain,4, data_start=1746.8088, data_stop=2707.6904) self.assertEqual(6306, len(depth_data)) #joinedStr = ', '.join(str(d) for d in depth_data) #logger.info(" joined depth data:"+joinedStr) @patch('sqlalchemy.orm.session.Session') def test_calcSteppedDepth1(self, mock_class): lasPersister = LasPersister(mock_class) data = [] logDomain = LogDomain() logDomain.log_start = 1 logDomain.log_stop = 10 logDomain.log_step = 1 depth_data = lasPersister.calcSteppedDepth(logDomain,4, data_start=1, data_stop=10) self.assertEqual(10, len(depth_data)) joinedStr = ', '.join(str(d) for d in depth_data) logger.info(" joined depth data:"+joinedStr) '''
def __init__(self, *args, **kwargs): super(HeaderViewerTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup()
def __init__(self, *args, **kwargs): super(DomainTrackWidgetTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() self.app = QApplication(sys.argv)
class TemplateSettingsDialogTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(TemplateSettingsDialogTest, self).__init__(*args, **kwargs) #QWidget: Must construct a QApplication before a QPaintDevice #self.app = QApplication(sys.argv) self.dummyDbSetup = DummyDbSetup() def test_init(self): #test that all input logs are automatically checked in the table logger.debug( "=================================================================" ) logger.debug(">>test_init() ") app = QApplication(sys.argv) well, logPlotData = self.generateLogPlotData() layoutDialog = TemplateSettingsDialog(logPlotData, well) self.assertEqual(WellPlotType.ALLLOGS.name, layoutDialog._itemWidget.nameLineEdit.text(), "Name is incorrect") self.assertEqual(WellPlotType.ALLLOGS.typeName, layoutDialog._itemWidget.classLineEdit.text(), "Type name is incorrect") def getCurrentlyPlottedLogs(self, logPlotData): plotLogs = [] plotList = logPlotData.sub_plots for subPlotData in plotList: for log in subPlotData.getLogs(): plotLogs.append(log) return plotLogs def generateLogPlotData(self): ''' using wellplot method to create data - preferred way may want to put data creation outside wellplot? ''' logger.debug(">>test_generateLogPlotData() ") self.dummyDbSetup.setupDatabase() #QWidget: Must construct a QApplication before a QPaintDevice #app = QApplication(sys.argv) well = self.dummyDbSetup.createWell() logs = self.dummyDbSetup.create3Logs(well.id) templateDao = WellPlotTemplateDao() allTemplates = templateDao.getAllWellPlotTemplates() template = None uid = 42 for item in allTemplates: if item.uid == WellPlotType.ALLLOGS.uid: template = item wellPlot = WellPlotPG(logs, well, template) wellPlotModelAccess = WellPlotModelAccess() wellPlotData = wellPlotModelAccess.createWellPlotData( logs, uid, well, template) return well, wellPlotData ''' def test_logData(self): logger.debug(">>test_logData() ") self.setupDatabase() #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) well = self.createWell() logs = self.createLogs(well.id) for log in logs: logger.debug("--test_logData() log name: {0} type: {1} id: {2}".format(log.name, log.log_type, log.id)) units = LogDao.getUnits(log) logger.debug("--test_logData() units: {0} ".format(units)) logger.debug("--------------------------------------") ''' '''
def __init__(self, *args, **kwargs): super(TemplateSettingsDialogTest, self).__init__(*args, **kwargs) #QWidget: Must construct a QApplication before a QPaintDevice #self.app = QApplication(sys.argv) self.dummyDbSetup = DummyDbSetup()
class WellDaoTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(WellDaoTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup() def createWell(self, mdstart, mdstop, wellName): logger.debug(">>createWell() ") session = DM.getSession() well = Well() well.name = wellName well.depth_reference = "MDKB" well.elevation_of_depth_reference = "24.0" well.mdstart = mdstart well.mdstop = mdstop session.add(well) session.commit() dummyWell = session.query(Well).filter(Well.name == wellName).one() assert wellName == dummyWell.name session.close() return dummyWell def test_getMdLength(self): #QWidget: Must construct a QApplication before a QPaintDevice app = QApplication(sys.argv) self.dummyDbSetup.setupDatabase() well = self.createWell(-200, -1200, 'first') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(1000, mdLength) well = self.createWell(-200, -100, 'second') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(100, mdLength) well = self.createWell(200, -1200, 'third') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(1400, mdLength, "start: 200 stop: -1200") well = self.createWell(200, 1200, 'fourth') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(1000, mdLength) well = self.createWell(200, 100, 'fifth') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(100, mdLength) well = self.createWell(-200, 1200, 'sixth') #logs = self.dummyDbSetup.create1Log(well.id) mdLength = well.getMdLength() logger.debug("--test_getMdLength() mdLength:{0}".format(mdLength)) self.assertEqual(1400, mdLength)
def __init__(self, *args, **kwargs): logger.debug(">>__init__()") super(WellPlotDefaultsInitializerTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup()
def __init__(self, *args, **kwargs): super(WellDaoTest, self).__init__(*args, **kwargs) self.dummyDbSetup = DummyDbSetup()