Beispiel #1
0
    def test_jcmt_available(self):
        """
        Test methods associated with the "jcmt_available" table.
        """

        (queue_id, call_id) = self._create_test_call()

        records = self.db.search_jcmt_available(call_id)

        self.assertIsInstance(records, JCMTAvailableCollection)
        self.assertEqual(len(records), 0)

        records = JCMTAvailableCollection()
        records[1] = JCMTAvailable(None, 1, JCMTWeather.BAND1, 100.0)

        with self.assertRaisesRegexp(ConsistencyError, 'call does not exist'):
            self.db.sync_jcmt_call_available(1999999, records)

        n = self.db.sync_jcmt_call_available(call_id, records)

        self.assertEqual(n, (1, 0, 0))

        records = self.db.search_jcmt_available(call_id=call_id)

        self.assertIsInstance(records, JCMTAvailableCollection)
        self.assertEqual(len(records), 1)

        for (id_, record) in records.items():
            self.assertIsInstance(id_, int)
            self.assertIsInstance(record, JCMTAvailable)
            self.assertEqual(record.id, id_)
            self.assertEqual(record.weather, JCMTWeather.BAND1)
            self.assertEqual(record.time, 100.0)
Beispiel #2
0
    def test_jcmt_available(self):
        """
        Test methods associated with the "jcmt_available" table.
        """

        (queue_id, call_id) = self._create_test_call()

        records = self.db.search_jcmt_available(call_id)

        self.assertIsInstance(records, JCMTAvailableCollection)
        self.assertEqual(len(records), 0)

        records = JCMTAvailableCollection()
        records[1] = JCMTAvailable(None, 1, JCMTWeather.BAND1, 100.0)

        with self.assertRaisesRegexp(ConsistencyError, 'call does not exist'):
            self.db.sync_jcmt_call_available(1999999, records)

        n = self.db.sync_jcmt_call_available(call_id, records)

        self.assertEqual(n, (1, 0, 0))

        records = self.db.search_jcmt_available(call_id=call_id)

        self.assertIsInstance(records, JCMTAvailableCollection)
        self.assertEqual(len(records), 1)

        for (id_, record) in records.items():
            self.assertIsInstance(id_, int)
            self.assertIsInstance(record, JCMTAvailable)
            self.assertEqual(record.id, id_)
            self.assertEqual(record.weather, JCMTWeather.BAND1)
            self.assertEqual(record.time, 100.0)
Beispiel #3
0
    def test_available_collection(self):
        c = JCMTAvailableCollection()

        c[1001] = JCMTAvailable(1001, 100, 2, 10.0)
        c[1002] = JCMTAvailable(1002, 100, 5, 15.0)

        # Test the "get_total" method.
        total = c.get_total()
        self.assertIsInstance(total, JCMTRequestTotal)
        self.assertEqual(total.total, 25)
        self.assertEqual(total.weather, {2: 10.0, 5: 15.0})
        self.assertEqual(total.instrument, {})
        self.assertEqual(total.total_non_free, 10)

        # Test the "validate" method.
        c.validate()

        c[1003] = JCMTAvailable(1003, 100, 5, 20.0)

        with self.assertRaisesRegexp(UserError, 'There are multiple entries'):
            c.validate()