Skip to content

Commit

Permalink
check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mworion committed Jun 18, 2024
1 parent 3679af4 commit 7b0c1a3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 81 deletions.
5 changes: 5 additions & 0 deletions mw4/gui/mainWmixin/astroObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def procSourceData(self):
def loadSourceUrl(self):
"""
"""
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
print('caller name:', calframe[1][1], calframe[1][3])

self.objects = None
key = self.uiSourceList.currentText()
if not key:
Expand Down
1 change: 0 additions & 1 deletion mw4/gui/mainWmixin/tabComet.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(self):

self.comets.dataLoaded.connect(self.fillCometListName)
self.ui.cometFilterText.textChanged.connect(self.filterListComets)

self.ui.progCometSelected.clicked.connect(self.comets.progSelected)
self.ui.progCometFiltered.clicked.connect(self.comets.progFiltered)
self.ui.progCometFull.clicked.connect(self.comets.progFull)
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
- add native support for Macs with Apple silicon
- add: support automation with 10micron webservices
- add: support uploading mechanism for databases for macos and linux
- add: show free disk space of work dir in the status bar
- add: show free disk space of work dir in the status bar
- add: support for comet and asteroid data in extended downloads
- change: faster and more reliable uploading mechanism for databases
- change: celestrak interface url's and retrieval strategy
- change: moving PyQt5 to major version PySide6
Expand Down Expand Up @@ -86,7 +87,7 @@
],
python_requires='>=3.9.0, <3.13',
install_requires=[
'numpy==1.26.4',
'numpy==2.0.0',
'opencv-python-headless==4.10.0.82',
'scipy==1.13.1',
'astropy==5.3.4',
Expand Down
11 changes: 0 additions & 11 deletions tests/unit_tests/gui/mainWmixin1/test_tabAsteroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from gui.utilities.toolsQtWidget import MWidget
from gui.widgets.main_ui import Ui_MainWindow
from gui.mainWmixin.tabAsteroid import Asteroid
from gui.mainWmixin.astroObjects import AstroObjects
from logic.databaseProcessing.sourceURL import asteroidSourceURLs


@pytest.fixture(autouse=True, scope='module')
Expand All @@ -43,15 +41,6 @@ def __init__(self):
self.threadPool = QThreadPool()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.asteroids = AstroObjects(self,
self.app,
'asteroid',
asteroidSourceURLs,
self.ui.listAsteroids,
self.ui.asteroidSourceList,
self.ui.asteroidSourceGroup,
self.processAsteroids)

Asteroid.__init__(self)

window = Mixin()
Expand Down
10 changes: 0 additions & 10 deletions tests/unit_tests/gui/mainWmixin1/test_tabComet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from gui.utilities.toolsQtWidget import MWidget
from gui.widgets.main_ui import Ui_MainWindow
from gui.mainWmixin.tabComet import Comet
from gui.mainWmixin.astroObjects import AstroObjects
from logic.databaseProcessing.sourceURL import cometSourceURLs


@pytest.fixture(autouse=True, scope='module')
Expand All @@ -43,14 +41,6 @@ def __init__(self):
self.threadPool = QThreadPool()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.comets = AstroObjects(self,
self.app,
'comet',
cometSourceURLs,
self.ui.listComets,
self.ui.cometSourceList,
self.ui.cometSourceGroup,
self.processComets)
Comet.__init__(self)

window = Mixin()
Expand Down
14 changes: 2 additions & 12 deletions tests/unit_tests/gui/mainWmixin2/test_tabSat_Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# standard libraries
import pytest
from unittest import mock
import os

# external packages
from PySide6.QtCore import QThreadPool, QRect
Expand All @@ -32,8 +31,6 @@
from gui.widgets.main_ui import Ui_MainWindow
from gui.mainWmixin.tabSat_Search import SatSearch
from gui.mainWmixin.tabSat_Track import SatTrack
from gui.mainWmixin.astroObjects import AstroObjects
from logic.databaseProcessing.sourceURL import satSourceURLs


@pytest.fixture(autouse=True, scope='module')
Expand All @@ -47,13 +44,6 @@ def __init__(self):
self.threadPool = QThreadPool()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.satellites = AstroObjects(self, self.app,
'satellite',
satSourceURLs,
self.ui.listSats,
self.ui.cometSourceList,
self.ui.satSourceGroup,
self.processSatellites)
SatSearch.__init__(self)
SatTrack.__init__(self)

Expand All @@ -62,8 +52,8 @@ def __init__(self):


def test_initConfig_1(function):
with mock.patch.object(function.satellites,
'loadSourceUrl'):
with mock.patch.object(function.ui.satSourceList,
'setCurrentIndex'):
function.initConfig()


Expand Down
76 changes: 37 additions & 39 deletions tests/unit_tests/gui/mainWmixin2/test_tabSat_Track.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,50 +501,50 @@ def test_showSatPasses_3(function):


def test_extractSatelliteData_0(function):
function.satellites = {'NOAA 8': 'sat',
'Test1': 'sat'}
function.satellites.objects = {'NOAA 8': 'sat',
'Test1': 'sat'}

function.satTableBaseValid = False
suc = function.extractSatelliteData(satName='Tjan')
assert not suc


def test_extractSatelliteData_1(function):
function.satellites = {'NOAA 8': 'sat',
'Test1': 'sat'}
function.satellites.objects = {'NOAA 8': 'sat',
'Test1': 'sat'}

function.satTableBaseValid = True
suc = function.extractSatelliteData(satName='Tjan')
assert not suc


def test_extractSatelliteData_2(function):
function.ui.listSatelliteNames.clear()
function.satellites = {'Test0': '',
'Test1': ''}
function.ui.listSats.clear()
function.satellites.objects = {'Test0': '',
'Test1': ''}

function.satTableBaseValid = True
suc = function.extractSatelliteData(satName='NOAA 8')
assert not suc


def test_extractSatelliteData_3(function):
function.ui.listSatelliteNames.setRowCount(0)
function.ui.listSatelliteNames.setColumnCount(2)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setRowCount(0)
function.ui.listSats.setColumnCount(2)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('NOAA 8')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setItem(0, 1, entry)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('Test1')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSats.setItem(0, 1, entry)

tle = ["NOAA 8",
"1 13923U 83022A 20076.90417581 .00000005 00000-0 19448-4 0 9998",
"2 13923 98.6122 63.2579 0016304 96.9736 263.3301 14.28696485924954"]
sat = EarthSatellite(tle[1], tle[2], name=tle[0])

function.satellites = {'NOAA 8': sat,
'Test1': sat}
function.satellites.objects = {'NOAA 8': sat,
'Test1': sat}
function.satTableBaseValid = True
ts = function.app.mount.obsSite.ts
with mock.patch.object(function.app.mount.obsSite.ts,
Expand All @@ -557,22 +557,22 @@ def test_extractSatelliteData_3(function):


def test_extractSatelliteData_4(function):
function.ui.listSatelliteNames.setRowCount(0)
function.ui.listSatelliteNames.setColumnCount(2)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setRowCount(0)
function.ui.listSats.setColumnCount(2)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('NOAA 8')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setItem(0, 1, entry)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('Test1')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSats.setItem(0, 1, entry)

tle = ["NOAA 8",
"1 13923U 83022A 20076.90417581 .00000005 00000-0 19448-4 0 9998",
"2 13923 98.6122 63.2579 0016304 96.9736 263.3301 14.28696485924954"]
sat = EarthSatellite(tle[1], tle[2], name=tle[0])

function.satellites = {'NOAA 8': sat,
'Test1': sat}
function.satellites.objects = {'NOAA 8': sat,
'Test1': sat}
function.satTableBaseValid = True
ts = function.app.mount.obsSite.ts
with mock.patch.object(function.app.mount.obsSite.ts,
Expand All @@ -585,22 +585,22 @@ def test_extractSatelliteData_4(function):


def test_extractSatelliteData_5(function):
function.ui.listSatelliteNames.setRowCount(0)
function.ui.listSatelliteNames.setColumnCount(2)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setRowCount(0)
function.ui.listSats.setColumnCount(2)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('NOAA 8')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSatelliteNames.insertRow(0)
function.ui.listSats.setItem(0, 1, entry)
function.ui.listSats.insertRow(0)
entry = QTableWidgetItem('Test1')
function.ui.listSatelliteNames.setItem(0, 1, entry)
function.ui.listSats.setItem(0, 1, entry)

tle = ["NOAA 8",
"1 13923U 83022A 20076.90417581 .00000005 00000-0 19448-4 0 9998",
"2 13923 98.6122 63.2579 0016304 96.9736 263.3301 14.28696485924954"]
sat = EarthSatellite(tle[1], tle[2], name=tle[0])

function.satellites = {'NOAA 8': sat,
'Test1': sat}
function.satellites.objects = {'NOAA 8': sat,
'Test1': sat}
function.satTableBaseValid = True
ts = function.app.mount.obsSite.ts
with mock.patch.object(function.app.mount.obsSite.ts,
Expand All @@ -627,7 +627,7 @@ def test_programDataToMount_3(function):
"1 37820U 11053A 14314.79851609 .00064249 00000-0 44961-3 0 5637",
"2 37820 42.7687 147.7173 0010686 283.6368 148.1694 15.73279710179072"]
function.satellite = EarthSatellite(tle[1], tle[2], name=tle[0])
function.satellites = {'TIANGONG 2': EarthSatellite(tle[1], tle[2], name=tle[0])}
function.satellites.objects = {'TIANGONG 2': EarthSatellite(tle[1], tle[2], name=tle[0])}
function.app.mount.satellite.tleParams.name = 'TIANGONG 2'
with mock.patch.object(function.app.mount.satellite,
'setTLE',
Expand All @@ -641,7 +641,7 @@ def test_programDataToMount_4(function):
"1 37820U 11053A 14314.79851609 .00064249 00000-0 44961-3 0 5637",
"2 37820 42.7687 147.7173 0010686 283.6368 148.1694 15.73279710179072"]
function.satellite = EarthSatellite(tle[1], tle[2], name=tle[0])
function.satellites = {'TIANGONG 2': EarthSatellite(tle[1], tle[2], name=tle[0])}
function.satellites.objects = {'TIANGONG 2': EarthSatellite(tle[1], tle[2], name=tle[0])}
function.app.mount.satellite.tleParams.name = 'TIANGONG 2'
with mock.patch.object(function.app.mount.satellite,
'setTLE',
Expand All @@ -653,29 +653,27 @@ def test_programDataToMount_4(function):


def test_chooseSatellite_1(function):
satTab = function.ui.listSatelliteNames
satTab = function.ui.listSats
function.app.deviceStat['mount'] = True
with mock.patch.object(satTab,
'item'):
with mock.patch.object(function,
'extractSatelliteData'):
with mock.patch.object(function,
'showSatPasses'):
suc = function.chooseSatellite()
assert suc
function.chooseSatellite()


def test_chooseSatellite_2(function):
satTab = function.ui.listSatelliteNames
satTab = function.ui.listSats
function.app.deviceStat['mount'] = False
with mock.patch.object(satTab,
'item'):
with mock.patch.object(function,
'extractSatelliteData'):
with mock.patch.object(function,
'showSatPasses'):
suc = function.chooseSatellite()
assert suc
function.chooseSatellite()


def test_getSatelliteDataFromDatabase_1(function):
Expand Down
12 changes: 6 additions & 6 deletions tests/unit_tests/zMainApp/test_mainApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

# local import
from mainApp import MountWizzard4
from gui.mainWmixin.astroObjects import AstroObjects
from base.loggerMW import setupLogging
import resource.resources as res
res.qInitResources()
Expand Down Expand Up @@ -57,13 +58,12 @@ def emit(self):
'start'):
with mock.patch.object(QBasicTimer,
'start'):
app = MountWizzard4(mwGlob=mwGlob, application=qapp)
app.log = logging.getLogger()
app.update1s = Test()
with mock.patch.object(app.mainW,
'setupSatelliteNameList'):
with mock.patch.object(AstroObjects,
'loadSourceUrl'):
app = MountWizzard4(mwGlob=mwGlob, application=qapp)
app.log = logging.getLogger()
app.update1s = Test()
yield app
app.threadPool.waitForDone(5000)


def test_storeStatusOperationRunning(app):
Expand Down

0 comments on commit 7b0c1a3

Please sign in to comment.