Exemplo n.º 1
0
 def test_format_value(self):
     self.assertEquals(format_value('foo'), '"foo"')
     self.assertEquals(format_value('foo bar'), '"foo bar"')
     self.assertEquals(format_value('foo "and" bar'), '"foo \"and\" bar"')
     self.assertEquals(format_value(123), "123i")
     self.assertEquals(format_value(123.123), "123.123")
     self.assertEquals(format_value(True), "True")
     self.assertEquals(format_value(False), "False")
Exemplo n.º 2
0
 def test_format_value(self):
     self.assertEquals(format_value('foo'), '"foo"')
     self.assertEquals(format_value('foo bar'), '"foo bar"')
     self.assertEquals(format_value('foo "and" bar'), '"foo \"and\" bar"')
     self.assertEquals(format_value(123), "123i")
     self.assertEquals(format_value(123.123), "123.123")
     self.assertEquals(format_value(True), "True")
     self.assertEquals(format_value(False), "False")
Exemplo n.º 3
0
    def get_output_values(self) -> str:
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        sorted_values = sorted(metric_values.items())
        sorted_values = [(k, v) for k, v in sorted_values if v is not None]

        return ','.join('{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
Exemplo n.º 4
0
    def get_output_values(self):
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        sorted_values = sorted(metric_values.items())
        sorted_values = [(k, v) for k, v in sorted_values if v is not None]

        return u','.join(u'{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
Exemplo n.º 5
0
    def get_output_values(self):
        """
        Return an escaped string of comma separated value_name: value pairs
        """
        # Handle primitive values here and implicitly convert them to a dict because
        # it allows the API to be simpler.

        # Also influxDB mandates that each value also has a name so the default name
        # for any non-dict value is "value"
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        # Sort the values in lexicographically by value name
        sorted_values = sorted(metric_values.items())

        return ",".join("{0}={1}".format(format_string(k), format_value(v)) for k, v in sorted_values)
Exemplo n.º 6
0
    def get_output_values(self):
        """
        Return an escaped string of comma separated value_name: value pairs
        """
        # Handle primitive values here and implicitly convert them to a dict because
        # it allows the API to be simpler.

        # Also influxDB mandates that each value also has a name so the default name
        # for any non-dict value is "value"
        if not isinstance(self.values, dict):
            metric_values = {'value': self.values}
        else:
            metric_values = self.values

        # Sort the values in lexicographically by value name
        sorted_values = sorted(metric_values.items())

        return ",".join("{0}={1}".format(format_string(k), format_value(v))
                        for k, v in sorted_values)