Ejemplo n.º 1
0
    def test_query_assemble_error(self):
        """Test query_assemble with DELETE clause."""
        clause = ''
        namespace = 'kytos.kronos.telemetry.switches.1.interfaces.232'
        start = '1970-01-02T10:17:36Z'
        end = '1971-02-03T10:17:36Z'
        field = 'bytes_in'
        method = None
        group = None
        fill = None

        with self.assertRaises(BackendError):
            influx._query_assemble(clause, namespace, start, end, field,
                                   method, group, fill)
Ejemplo n.º 2
0
    def test_query_assemble_select_with_field_equals_none(self):
        """Test query_assemble with SELECT clause with field = None."""
        clause = 'SELECT'
        namespace = 'kytos.kronos.telemetry.switches.1.interfaces.232'
        start = '1970-01-02T10:17:36Z'
        end = '1971-02-03T10:17:36Z'
        field = None
        method = None
        group = None
        fill = None

        query = influx._query_assemble(clause, namespace, start, end, field,
                                       method, group, fill)
        expected_query = (f'SELECT * FROM "{namespace}" WHERE time  >= '
                          f'\'{str(start)}\' AND time <=\'{str(end)}\'')
        self.assertEqual(query, expected_query)
Ejemplo n.º 3
0
    def test_query_assemble_group_and_fill_options(self):
        """Test SELECT query using group and fill options."""
        clause = 'SELECT'
        namespace = 'kytos.kronos.telemetry.switches.1.interfaces.232'
        start = '1970-01-02T10:17:36Z'
        end = '1971-02-03T10:17:36Z'
        field = 'bytes_in'
        method = None
        group = '*'

        # Reports no timestamp and no value for time intervals with no data.
        fill = 'none'

        query = influx._query_assemble(clause, namespace, start, end, field,
                                       method, group, fill)
        expected_query = (f'SELECT bytes_in FROM "{namespace}" WHERE time  >= '
                          f'\'{str(start)}\' AND time <=\'{str(end)}\' '
                          f'GROUP BY time(*) fill(none)')
        self.assertEqual(query, expected_query)