def test_get_data_json(self):
        now = datetime.datetime.now()
        end = now - datetime.timedelta(minutes=1)
        start = end - datetime.timedelta(minutes=1)

        query = util.construct_data_query(
            channels=['SIN-CVME-TIFGUN-EVR0:BUNCH-1-OK'], start=start, end=end)
        data = client.get_data_json(query)

        value = data[0]["data"][0]
        logger.info(value)

        self.assertTrue("value" in value)
        self.assertTrue("time" in value)
        self.assertTrue("pulseId" in value)

        query = util.construct_data_query(
            channels=['SIN-CVME-TIFGUN-EVR0:BUNCH-1-OK'],
            start=start,
            end=end,
            value_mapping=util.construct_value_mapping(incomplete="fill-null"))
        data = client.get_data_json(query)

        value = data[0][0]  # first row first column
        logger.info(value)

        self.assertTrue("value" in value)
        self.assertTrue("time" in value)
        self.assertTrue("pulseId" in value)
    def test_get_data_idread_json_compare_image(self):
        """
        Test if get_data_json returns same data as get_data_idread
        """

        query = util.construct_data_query(
            channels=[
                'SF-IMAGEBUFFER/SLAAR21-LCAM-C511:FPICTURE',
                # 'SINEG01-RCIR-PUP10:SIG-AMPLT',
                # 'sf-databuffer/SINEG01-RCIR-PUP10:SIG-AMPLT-MAX'
            ],
            start=7928427268,
            end=7928427268)

        json_data = client.get_data_json(query)
        # print(json_data[0]["data"][:10])

        idread_data = client.get_data_idread(query)
        # print(idread_data[0]["data"][:10])

        for i in range(len(json_data[0]["data"])):
            self.assertTrue(json_data[0]["data"][i]["pulseId"] ==
                            idread_data[0]["data"][i]["pulseId"])
            self.assertTrue(
                numpy.array_equal(json_data[0]["data"][i]["value"],
                                  idread_data[0]["data"][i]["value"]))
    def test_get_data_idread_json_compare(self):
        """
        Test if get_data_json returns same data as get_data_idread
        """

        now = datetime.datetime.now()
        end = now - datetime.timedelta(minutes=1)
        start = end - datetime.timedelta(minutes=1)

        query = util.construct_data_query(
            channels=[
                'SIN-CVME-TIFGUN-EVR0:BUNCH-1-OK',
                # 'SINEG01-RCIR-PUP10:SIG-AMPLT',
                # 'sf-databuffer/SINEG01-RCIR-PUP10:SIG-AMPLT-MAX'
            ],
            start=start,
            end=end)

        json_data = client.get_data_json(query)
        print(json_data[0]["data"][:10])

        idread_data = client.get_data_idread(query)
        print(idread_data[0]["data"][:10])

        for i in range(len(json_data[0]["data"])):
            json_value = json_data[0]["data"][i]
            idread_value = idread_data[0]["data"][i]
            self.assertEqual(json_value["pulseId"], idread_value["pulseId"])
            self.assertEqual(json_value["value"], idread_value["value"])
Beispiel #4
0
    def test_get_data_long_timerange(self):
        # If this test fails check whether the used channels are currently available in the databuffer / archiver

        now = datetime.datetime.now()
        end = now - datetime.timedelta(minutes=1)
        start = end - datetime.timedelta(hours=12)

        query = util.construct_data_query(channels=['sf-archiverappliance/S10CB02-CVME-ILK:CENTRAL-CORETEMP',
                                                    'sf-archiverappliance/S10CB02-CVME-ILK:CENTRAL-CORETEMP2'],
                                          start=start, end=end)
        data = client.get_data_json(query)

        logger.info(data[0])
        self.assertTrue(True)
Beispiel #5
0
    def test_get_data_server_side_mapping(self):
        # When server side mapping is enabled the returned dictionary is different!
        # If this test fails check whether the used channels are currently available in the databuffer / archiver

        now = datetime.datetime.now()
        end = now - datetime.timedelta(minutes=1)
        start = end - datetime.timedelta(minutes=1)

        query = util.construct_data_query(channels=['SIN-CVME-TIFGUN-EVR0:BEAMOK',
                                                    'sf-archiverappliance/S10CB01-CVME-ILK:P2020-CORETEMP'],
                                          start=start, end=end,
                                          # value_mapping=util.construct_value_mapping(incomplete="fill-null"))
                            # value_mapping=util.construct_value_mapping(incomplete="drop"))
                            value_mapping=util.construct_value_mapping(incomplete="provide-as-is"))

        json_data = client.get_data_json(query)
        idread_data = client.get_data_idread(query)

        for i in range(len(json_data)):

            # logger.info(data['data'][i])
            json_value = json_data[i]
            idread_value = idread_data[i]

            # self.assertTrue(len(json_value) == len(idread_value))

            if json_value[0] is None:
                self.assertEqual(json_value[0], idread_value[0], "failed on index: %d" % i)
            else:
                self.assertTrue(json_value[0]["channel"] == "SIN-CVME-TIFGUN-EVR0:BEAMOK", "failed on index: %d" % i)
                self.assertTrue(idread_value[0]["channel"] == "SIN-CVME-TIFGUN-EVR0:BEAMOK", "failed on index: %d" % i)
                self.assertEqual(json_value[0]["value"], idread_value[0]["value"], "failed on index: %d" % i)

            if json_value[1] is None:
                self.assertEqual(json_value[1], idread_value[1], "failed on index: %d" % i)
            else:
                self.assertTrue(json_value[1]["channel"] == "S10CB01-CVME-ILK:P2020-CORETEMP", "failed on index: %d" % i)
                self.assertTrue(idread_value[1]["channel"] == "S10CB01-CVME-ILK:P2020-CORETEMP", "failed on index: %d" % i)
                self.assertEqual(json_value[1]["value"], idread_value[1]["value"], "failed on index: %d" % i)