Commit 78cb4526 authored by Marco Buttu's avatar Marco Buttu
Browse files

Tests 3 and 4 passed: LO inside the observed sky band

Test 3: LO inside the default observed sky band
Test 4: LO inside the (no-default) observed sky band
parent 95bcdbac
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ def run(test_case):

    FNULL = open(os.devnull, 'w')
    try:
        subprocess.Popen(['%s-sim start' %server_name], stdout=FNULL, stderr=FNULL)
        subprocess.Popen(['%s-sim' % server_name, 'start'], stdout=FNULL, stderr=FNULL)
        time.sleep(1) # Give the server the time to start
        suite = unittest2.TestSuite()
        tests = unittest2.TestLoader().loadTestsFromTestCase(test_case)
@@ -20,5 +20,5 @@ def run(test_case):
        print 'Running the tests using the antenna simulators...'
        unittest2.TextTestRunner(verbosity=2).run(suite)
    finally:
        subprocess.Popen(['%s-sim stop' %server_name], stdout=FNULL, stderr=FNULL)
        subprocess.Popen(['%s-sim' % server_name, 'stop'], stdout=FNULL, stderr=FNULL)
        time.sleep(2) # Give the server the time to stop
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ clean_test:
	rm -f pyunit/*.pyc
	rm -f external/*.pyc
	rm -rf ../lib/python/site-packages/*
	rm -rf $(INTROOT)/lib/python/site-packages/PyMinorServoTest*
	rm -rf $(INTROOT)/lib/python/site-packages/PyLPBandTest*

unit: do_unit
	@echo " . . . 'unit' done"
+3 −3
Original line number Diff line number Diff line
@@ -6,13 +6,13 @@ import subprocess

def run(test_case):
    # Use the simulators and the testing CDB
    server_name = 'receiverboard-sim' if test_case.telescope == 'SRT' else ''
    server_name = 'receiverboard' if test_case.telescope == 'SRT' else ''
    if not server_name:
        sys.exit(0) 

    FNULL = open(os.devnull, 'w')
    try:
        subprocess.Popen(['%s start' %server_name], stdout=FNULL, stderr=FNULL)
        subprocess.Popen(['%s-sim' %server_name, 'start'], stdout=FNULL, stderr=FNULL)
        time.sleep(1) # Give the server the time to start
        suite = unittest2.TestSuite()
        tests = unittest2.TestLoader().loadTestsFromTestCase(test_case)
@@ -20,5 +20,5 @@ def run(test_case):
        print 'Running the tests using the antenna simulators...'
        unittest2.TextTestRunner(verbosity=2).run(suite)
    finally:
        subprocess.Popen(['%s stop' %server_name], stdout=FNULL, stderr=FNULL)
        subprocess.Popen(['%s-sim' % server_name, 'stop'], stdout=FNULL, stderr=FNULL)
        time.sleep(2) # Give the server the time to stop
+21 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class TestLO(unittest2.TestCase):


    def test_set_below_minimum_value(self):
        """LO below the minimum allowed value: operation not allowed"""
        """LO below the minimum allowed value: not allowed"""
        min_values = get_cdb_values('LOMin')
        values_not_allowed = [(value - 0.5) for value in min_values]
        with self.assertRaises(ComponentErrorsEx):
@@ -52,13 +52,32 @@ class TestLO(unittest2.TestCase):


    def test_set_above_minimum_value(self):
        """LO above the minimum allowed value: operation not allowed"""
        """LO above the minimum allowed value: not allowed"""
        max_values = get_cdb_values('LOMax')
        values_not_allowed = [(value + 0.5) for value in max_values]
        with self.assertRaises(ComponentErrorsEx):
            self.lp.setLO(values_not_allowed)


    def test_lo_inside_default_sky_band(self):
        """LO inside the default (L3L4) observed sky band: not allowed"""
        # Check the bandwith is 1300:1800 MHz
        assert [1300.0] * 2 == get_cdb_values('LBandRFMin')
        assert [1800.0] * 2 == get_cdb_values('LBandRFMax')
        values_not_allowed = [1500.00, 1500.00]
        with self.assertRaisesRegexp(ComponentErrorsEx, 'within the band'):
            self.lp.setLO(values_not_allowed)


    def test_lo_inside_no_default_sky_band(self):
        """LO inside the (no-default) observed sky band"""
        self.lp.setMode('XXL5') # Bandwidth 1625:1715
        self.lp.setLO([1500.0, 1500.0]) # OK, it is outside the RF band
        values_not_allowed = [1650.00, 1650.00]
        with self.assertRaisesRegexp(ComponentErrorsEx, 'within the band'):
            self.lp.setLO(values_not_allowed)


def get_cdb_values(attr_name, type_=float):
    dal = ACSCorba.cdb()
    dao = dal.get_DAO('alma/DataBlock/SRTLPBandReceiver/Modes/L3L4')