Ejemplo n.º 1
0
    def test_multiprocess_data(self):
        """Testing method / function multiprocess_data."""
        # Initialize key variables
        items = make_records()
        timestamps = items['timestamps']
        records = items['records']
        expected = items['expected']
        checksum = items['checksum']

        # Entry should not exist
        result = datapoint.checksum_exists(checksum)
        self.assertFalse(result)

        # Test
        process = ingest_data.Records([records])
        process.multiprocess_pairs()
        process.multiprocess_data()

        # Get data from database
        idx_datapoint = datapoint.checksum_exists(checksum)
        _dp = datapoint.DataPoint(idx_datapoint)
        ts_start = min(timestamps)
        ts_stop = max(timestamps)
        results = _dp.data(ts_start, ts_stop)

        # Test
        for index, result in enumerate(results):
            self.assertEqual(result['value'], expected[index]['value'])
            self.assertEqual(result['timestamp'], expected[index]['timestamp'])
Ejemplo n.º 2
0
    def test_multiprocess_pairs(self):
        """Testing method / function multiprocess_pairs."""
        # Initialize key variables
        items = make_records()
        records = items['records']

        # Key-value pair should not exist
        for record in records:
            key = record.pattoo_key
            value = record.pattoo_value
            result = pair.pair_exists(key, value)
            self.assertFalse(result)

        # Insert pairs as necessary
        process = ingest_data.Records([records])
        process.multiprocess_pairs()

        # Key-value pair should exist
        for record in records:
            key = record.pattoo_key
            value = record.pattoo_value
            result = pair.pair_exists(key, value)
            self.assertFalse(result)