def test_read_polarisation_data_and_type_from_db(self): #create a muck parmdb parmdb = WritableParmDB("parmdb") parmdb.names = ["1:1:Real:name1", "1:1:Real:name2", "1:1:Real:name3", "1:1:Real:name4", "Gain:1:1:Real:test", "Gain:1:1:Imag:test", "Gain:0:0:Real:test", "Gain:0:0:Imag:test"] station = "test" #create sut GainOutlierDetection = GainOutlierCorrectionWrapper() (retrieved_data, type_pair) = GainOutlierDetection._read_polarisation_data_and_type_from_db(parmdb, station) #validate output!! value_dict = {"values":[[1., 1., 1., 1., 100., 100.], [1., 1., 1., 1., 100., 100.]], 'freqs':[2], 'freqwidths':[2], 'times':[2], 'timewidths':[2]} goal_retrieved_data = {'1:1': [value_dict, value_dict], '0:0': [value_dict, value_dict]} self.assertTrue(retrieved_data == goal_retrieved_data, "Incorrect data retrieved from the parmdb: {0}".format( retrieved_data)) goal_type_pair = ['Imag', 'Real'] self.assertTrue(type_pair == goal_type_pair, "Incorrect data retrieved from the parmdb: {0}".format( retrieved_data))
def test_read_polarisation_data_and_type_from_db_invalid_type_pair(self): #create a muck parmdb parmdb = WritableParmDB("parmdb") parmdb.names = [ "1:1:Real:name1", "1:1:Real:name2", "1:1:Real:name3", "1:1:Real:name4", "Gain:1:1:Real:test", "Gain:1:1:Imag:test", "Gain:0:0:incorrect_type:test", "Gain:0:0:Imag:test" ] station = "test" GainOutlierDetection = GainOutlierCorrectionWrapper() # unknown datatype should throw an exception self.assertRaises( PipelineRecipeFailed, GainOutlierDetection._read_polarisation_data_and_type_from_db, parmdb, station)
def test_read_polarisation_data_and_type_from_db_invalid_type_pair(self): #create a muck parmdb parmdb = WritableParmDB("parmdb") parmdb.names = ["1:1:Real:name1", "1:1:Real:name2", "1:1:Real:name3", "1:1:Real:name4", "Gain:1:1:Real:test", "Gain:1:1:Imag:test", "Gain:0:0:incorrect_type:test", "Gain:0:0:Imag:test"] station = "test" GainOutlierDetection = GainOutlierCorrectionWrapper() # unknown datatype should throw an exception self.assertRaises(PipelineRecipeFailed, GainOutlierDetection._read_polarisation_data_and_type_from_db, parmdb, station)