Пример #1
0
    def test_text_004(self):
        ''' check that a text formatter is returned for version 0.0.4 '''
        headers = ("text/plain; version=0.0.4", "text/plain;version=0.0.4",
                   "version=0.0.4; text/plain")

        for accept in headers:
            self.assertEqual(TextFormatter, negotiate(set(accept.split(';'))))
Пример #2
0
    def test_default(self):
        """ check that a text formatter is returned if no matches """
        headers = ("application/json", "*/*", "application/nothing")

        for accept in headers:
            self.assertEqual(text.TextFormatter,
                             negotiate(set(accept.split(";"))))
Пример #3
0
    def test_text_default(self):
        """ check that a text formatter is returned for plain text """
        headers = ("text/plain;", )

        for accept in headers:
            self.assertEqual(text.TextFormatter,
                             negotiate(set(accept.split(";"))))
Пример #4
0
    def test_text_default(self):
        ''' check that a text formatter is returned for plain text '''
        headers = (
            "text/plain;",)

        for accept in headers:
            self.assertEqual(
                TextFormatter, negotiate(set(accept.split(';'))))
Пример #5
0
    def test_protobuffer(self):
        """ check that a protobuf formatter is returned """
        headers = (
            "proto=io.prometheus.client.MetricFamily;application/vnd.google.protobuf;encoding=delimited",
            "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited",
            "encoding=delimited;application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily",
        )

        for accept in headers:
            self.assertEqual(BinaryFormatter, negotiate(set(accept.split(";"))))
Пример #6
0
    def test_protobuffer(self):
        """ check that a protobuf formatter is returned """
        headers = (
            "proto=io.prometheus.client.MetricFamily;application/vnd.google.protobuf;encoding=delimited",
            "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited",
            "encoding=delimited;application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily",
        )

        for accept in headers:
            self.assertEqual(BinaryFormatter, negotiate(set(accept.split(";"))))
Пример #7
0
    def test_text_004(self):
        """ check that a text formatter is returned for version 0.0.4 """
        headers = (
            "text/plain; version=0.0.4",
            "text/plain;version=0.0.4",
            "version=0.0.4; text/plain",
        )

        for accept in headers:
            self.assertEqual(TextFormatter, negotiate(set(accept.split(";"))))
Пример #8
0
    def test_default(self):
        ''' check that a text formatter is returned if no matches '''
        headers = (
            "application/json",
            "*/*",
            "application/nothing")

        for accept in headers:
            self.assertEqual(
                TextFormatter, negotiate(set(accept.split(';'))))
Пример #9
0
    def test_text_004(self):
        """ check that a text formatter is returned for version 0.0.4 """
        headers = (
            "text/plain; version=0.0.4",
            "text/plain;version=0.0.4",
            "version=0.0.4; text/plain",
        )

        for accept in headers:
            self.assertEqual(text.TextFormatter, negotiate(set(accept.split(";"))))
Пример #10
0
 def test_no_accept_header(self):
     """ check request with no accept header works """
     self.assertEqual(TextFormatter, negotiate(set()))
     self.assertEqual(TextFormatter, negotiate(set([""])))
Пример #11
0
 def test_no_accept_header(self):
     """ check request with no accept header works """
     self.assertEqual(TextFormatter, negotiate(set()))
     self.assertEqual(TextFormatter, negotiate(set([""])))
Пример #12
0
    def test_text_default(self):
        ''' check that a text formatter is returned for plain text '''
        headers = ("text/plain;", )

        for accept in headers:
            self.assertEqual(TextFormatter, negotiate(set(accept.split(';'))))