Skip to content
Snippets Groups Projects
Commit f498e222 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

Task #10559 - Mock for AntennasetsParser to avoid config file requirement

parent e6a7e97c
Branches
Tags
No related merge requests found
# $Id: CMakeLists.txt $ # $Id: CMakeLists.txt $
lofar_package(ResourceAssignmentEstimator 1.0 DEPENDS PyMessaging PyCommon pyparameterset) lofar_package(ResourceAssignmentEstimator 1.0 DEPENDS PyMessaging PyCommon pyparameterset PyStationModel)
lofar_find_package(Python 2.6 REQUIRED) lofar_find_package(Python 2.6 REQUIRED)
include(PythonInstall) include(PythonInstall)
......
"{'1': {'observation': {'errors': [], 'estimates': [{'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 0, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 1, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 2, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 0, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 1, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 2, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CS004', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS004RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS004RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS005', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS005RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS005RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS003', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS003RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS003RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS002', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS002RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS002RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS007', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS007RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS007RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS006', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'}, 'resource_count': 1}, {'root_resource_group': 'CS006RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS006RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}]}}}" "{'1': {'observation': {'errors': [], 'estimates': [{'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 0, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 1, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 73, 'output_files': {'cs': {'cs_otdb_id': 1, 'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.cs'], 'nr_of_cs_stokes': 1}, 'saps': [{'sap_nr': 2, 'properties': {'cs_file_size': 76441190400, 'nr_of_cs_parts': 1, 'is_tab_nr': 12, 'nr_of_cs_files': 1}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 0, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 1, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CEP4', 'resource_types': {'bandwidth': 169869312, 'storage': 76441190400}, 'resource_count': 1, 'output_files': {'is': {'identifications': ['mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP0.1296.SAP0.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP1.1296.SAP1.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is', 'mom.G735371.LOTAAS-P1296B-SAP2.1296.SAP2.obs.is'], 'is_otdb_id': 1, 'nr_of_is_stokes': 1}, 'saps': [{'sap_nr': 2, 'properties': {'is_file_size': 76441190400, 'nr_of_is_files': 1, 'is_tab_nr': 12}}]}}, {'root_resource_group': 'CS004', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS004RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS004RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS005', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS005RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS005RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS003', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS003RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS003RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS002', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS002RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS002RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS007', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS007RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS007RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS006', 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100'}, 'resource_count': 1}, {'root_resource_group': 'CS006RSP0', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}, {'root_resource_group': 'CS006RSP1', 'resource_types': {'rsp': 3888, 'bandwith': 3000000000}, 'resource_count': 1}]}}}"
...@@ -5,6 +5,7 @@ import unittest ...@@ -5,6 +5,7 @@ import unittest
from pprint import pprint from pprint import pprint
import logging import logging
from lofar.sas.resourceassignment.resourceassignmentestimator.service import ResourceEstimatorHandler from lofar.sas.resourceassignment.resourceassignmentestimator.service import ResourceEstimatorHandler
import mock
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -15,6 +16,19 @@ logger = logging.getLogger(__name__) ...@@ -15,6 +16,19 @@ logger = logging.getLogger(__name__)
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
DO_GENERATE_GOLDEN_OUTPUTS = False DO_GENERATE_GOLDEN_OUTPUTS = False
def mock_receiver_units_configuration_per_station(dont_care,stations):
rcudict = {}
mockvalues = {"other": 192 * ["LBH"],
"CS": 23 * (2 * ["LBL"] + 2 * ["LBH"]) + (2 * ["LBL"] + 2 * [None]),
"RS": 23 * (2 * ["LBL"] + 2 * ["LBH"]) + (2 * ["LBL"] + 2 * [None])
}
for station in stations:
if station[:2] in mockvalues:
rcudict[station]=mockvalues[station[:2]]
else:
rcudict[station]=mockvalues['other']
print rcudict
return rcudict
class TestEstimationsAgainstGoldenOutput(unittest.TestCase): class TestEstimationsAgainstGoldenOutput(unittest.TestCase):
""" """
...@@ -33,9 +47,11 @@ class TestEstimationsAgainstGoldenOutput(unittest.TestCase): ...@@ -33,9 +47,11 @@ class TestEstimationsAgainstGoldenOutput(unittest.TestCase):
# ------------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------------
# Test estimation for observations # Test estimation for observations
def test_estimate_for_beam_observation(self): @mock.patch('lofar.sas.resourceassignment.resourceassignmentestimator.resource_estimators.observation.AntennaSetsParser')
def test_estimate_for_beam_observation(self, mock_asp):
""" Verify estimation for a beam observation specification tree against the golden output. """ """ Verify estimation for a beam observation specification tree against the golden output. """
# Arrange # Arrange
mock_asp().get_receiver_units_configuration_per_station=mock_receiver_units_configuration_per_station
data_set_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.in_beam_observation') data_set_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.in_beam_observation')
golden_output_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.out_beam_observation') golden_output_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.out_beam_observation')
task_type = 'observation' task_type = 'observation'
...@@ -55,9 +71,12 @@ class TestEstimationsAgainstGoldenOutput(unittest.TestCase): ...@@ -55,9 +71,12 @@ class TestEstimationsAgainstGoldenOutput(unittest.TestCase):
self.assertEqual(len(error_messages), 0, "\nThe uut reported errors:\n" + '\n- '.join(error_messages)) self.assertEqual(len(error_messages), 0, "\nThe uut reported errors:\n" + '\n- '.join(error_messages))
self.assertEqual(self.get_datastructure_as_string(estimation), golden_estimation) self.assertEqual(self.get_datastructure_as_string(estimation), golden_estimation)
def test_estimate_for_interferometer_observation(self): @mock.patch('lofar.sas.resourceassignment.resourceassignmentestimator.resource_estimators.observation.AntennaSetsParser',
get_receiver_units_configuration_per_station=mock_receiver_units_configuration_per_station)
def test_estimate_for_interferometer_observation(self, mock_asp):
""" Verify estimation for a interferometer observation specification tree against the golden output. """ """ Verify estimation for a interferometer observation specification tree against the golden output. """
# Arrange # Arrange
mock_asp().get_receiver_units_configuration_per_station=mock_receiver_units_configuration_per_station
data_set_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.in_interferometer_observation') data_set_filepath = os.path.join(self.data_sets_dir, 't_resource_estimator.in_interferometer_observation')
golden_output_filepath = os.path.join(self.data_sets_dir, golden_output_filepath = os.path.join(self.data_sets_dir,
't_resource_estimator.out_interferometer_observation') 't_resource_estimator.out_interferometer_observation')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment