Exemple #1
0
    def testParsingNothing(self):
        # RFC 2616, 14.1 - If no Accept header field is present,
        #                  then it is assumed that the client
        #                  accepts all media types.
        liberal = MediaTypeAcceptor(None)
        assert liberal.accepts("text/html")
        assert liberal.accepts("anyold/thing")

        liberal = MediaTypeAcceptor("")
        assert liberal.accepts("text/html")
        assert liberal.accepts("anyold/thing")
Exemple #2
0
 def testParsingFirefoxsDefaultAccept(self):
     firefox = MediaTypeAcceptor(FirefoxAcceptString)
     assert firefox.accepts("application/xml")
     assert firefox.accepts("application/xhtml+xml")
     assert firefox.accepts("text/html")
     assert firefox.accepts("text/plain")
     assert firefox.accepts("image/png")
     assert firefox.accepts("anyold/thing")
Exemple #3
0
 def testParsingChromiumsDefaultAccept(self):
     chromium = MediaTypeAcceptor(ChromiumAcceptString)
     assert chromium.accepts("application/xml")
     assert chromium.accepts("application/xhtml+xml")
     assert chromium.accepts("text/html")
     assert chromium.accepts("text/plain")
     assert chromium.accepts("image/png")
     assert chromium.accepts("anyold/thing")
Exemple #4
0
 def testParsingTwoTypes(self):
     focused = MediaTypeAcceptor("application/json,text/html")
     assert focused.accepts("application/json")
     assert focused.accepts("text/html")
     assert not focused.accepts("image/jpeg")
     assert not focused.accepts("anyold/thing")
Exemple #5
0
 def testParsingOneType(self):
     focused = MediaTypeAcceptor("application/json")
     assert focused.accepts("application/json")
     assert not focused.accepts("text/html")
     assert not focused.accepts("anyold/thing")
Exemple #6
0
 def testParsingHorrorShowAll(self):
     liberal = MediaTypeAcceptor("*")
     assert liberal.accepts("text/html")
     assert liberal.accepts("anyold/thing")
Exemple #7
0
 def testParsingTwoRanges(self):
     visual_and_textual = MediaTypeAcceptor("image/*,text/*")
     assert visual_and_textual.accepts("image/png")
     assert visual_and_textual.accepts("image/jpeg")
     assert visual_and_textual.accepts("text/plain")
     assert not visual_and_textual.accepts("application/json")
Exemple #8
0
 def testParsingOneTypeRange(self):
     visual = MediaTypeAcceptor("image/*")
     assert visual.accepts("image/png")
     assert visual.accepts("image/jpeg")
     assert not visual.accepts("application/json")
     assert not visual.accepts("text/plain")