Skip to content

Commit

Permalink
tweaks to DM Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-McCann-HG committed Apr 21, 2024
1 parent a33efdd commit fc299dd
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions QGIS-AIMS-Plugin/test/DataManager_Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#user to init an address, simple text string read from a stored config file
ref_int = 1234

INIT = True
SW1,NE1 = (174.76918,-41.28515),(174.79509,-41.26491)
TS0,TS1,TS2 = 5, 20, 60
'''
Expand Down Expand Up @@ -129,7 +130,7 @@ def test20_refreshTest(self):


class Test_3_DataManagerCFRF(unittest.TestCase):
init = True

'''tests whether the CF and RF feeds get populated'''
def setUp(self):
self.dm = self.initDM()
Expand All @@ -138,10 +139,9 @@ def setUp(self):
self.ar = FeedRef((FeatureType.ADDRESS,FeedType.RESOLUTIONFEED))

def initDM(self) -> DataManager:
dm = DataManager(initialise=self.init)
if self.init:
dm.pull()
self.init = False
global INIT
dm = DataManager(initialise=INIT)
if INIT: INIT = False
return dm

def tearDown(self):
Expand All @@ -157,13 +157,17 @@ def test10_rf(self):
len1 = self.dm.persist.ADL.get(self.ar)
print(f'Test_3_DataManagerCFRF -- LEN 1: {len1}')
time.sleep(TS1)
print(f'Test_3_DataManagerCFRF -- LEN 1: {len2}')
len2 = self.dm.persist.ADL.get(self.ar)
print(f'Test_3_DataManagerCFRF -- LEN 2: {len2}')
self.assertNotEqual(len1,len2,'Resolutionfeed didn\'t update within {} seconds'.format(TS1))

@classmethod
def tearDownClass(cls) -> None:
global INIT
INIT = True
return super().tearDownClass()

class Test_4_DataManagerShift(unittest.TestCase):

init = True

def setUp(self):
self.dm = self.initDM()
Expand All @@ -172,9 +176,9 @@ def setUp(self):
self.ar = FeedRef((FeatureType.ADDRESS,FeedType.RESOLUTIONFEED))

def initDM(self) -> DataManager:
dm = DataManager(initialise=self.init)
dm.pull()
self.init = False
global INIT
dm = DataManager(initialise=INIT)
if INIT: INIT = False
return dm

def tearDown(self):
Expand All @@ -187,12 +191,17 @@ def test10_shift(self):
len2 = self.dm.persist.ADL[self.af]

self.assertNotEqual(len1,len2,'Features feed didn\'t update within {} seconds'.format(TS1))

@classmethod
def tearDownClass(cls) -> None:
global INIT
INIT = True
return super().tearDownClass()


class Test_5_DataManagerChangeFeed(unittest.TestCase):

ver = 1000000
init = True

def setUp(self):
self.dm = self.initDM()
Expand All @@ -206,9 +215,9 @@ def setUp(self):
self.addr_f = _getTestAddress(self.afc)

def initDM(self) -> DataManager:
dm = DataManager(initialise=self.init)
dm.pull()
self.init = False
global INIT
dm = DataManager(initialise=INIT)
if INIT: INIT = False
return dm

def tearDown(self):
Expand Down Expand Up @@ -254,6 +263,12 @@ def test40_retire(self):
self.assertTrue(isinstance(r, AddressChange))
time.sleep(5)

@classmethod
def tearDownClass(cls) -> None:
global INIT
INIT = True
return super().tearDownClass()

class Test_6_DataManagerResolutionFeed(unittest.TestCase):

ver = 1000000
Expand All @@ -270,11 +285,10 @@ def setUp(self):
self.addr_f = _getTestAddress(self.afr)

def initDM(self) -> DataManager:
dm = DataManager(initialise=self.init)
dm.pull()
self.init = False
global INIT
dm = DataManager(initialise=INIT)
if INIT: INIT = False
return dm


def tearDown(self):
self.dm.close()
Expand Down Expand Up @@ -321,6 +335,12 @@ def test40_reject(self):
resp = self.dm.response(self.ar)
for r in resp:
self.assertTrue(isinstance(r, AddressResolution))

@classmethod
def tearDownClass(cls) -> None:
global INIT
INIT = True
return super().tearDownClass()


# --------------------------------------------------------------------
Expand Down

0 comments on commit fc299dd

Please sign in to comment.