Example #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 = LanguageAcceptor(None)
        assert liberal.accepts("en-US")
        assert liberal.accepts("anything-anywhere")

        liberal = LanguageAcceptor("")
        assert liberal.accepts("en-US")
        assert liberal.accepts("anything-anywhere")
Example #2
0
 def testParsingOneTypeRangeAndOneType(self):
     bilingual = LanguageAcceptor("es,en-US")
     assert bilingual.accepts("en-US")
     assert bilingual.accepts("es")
     assert bilingual.accepts("en")
     assert not bilingual.accepts("de")
Example #3
0
 def testParsingOneTypeRange(self):
     english = LanguageAcceptor("en-US,en-GB,en")
     assert english.accepts("en-US")
     assert english.accepts("en-GB")
     assert not english.accepts("es")
     assert not english.accepts("es-SP")
Example #4
0
 def testParsingTwoTypes(self):
     focused = LanguageAcceptor("en-US,en-GB")
     assert focused.accepts("en-US")
     assert focused.accepts("en-GB")
     assert not focused.accepts("es")
     assert not focused.accepts("es-SP")
Example #5
0
 def testParsingOneType(self):
     focused = LanguageAcceptor("en-US")
     assert focused.accepts("en-US")
     assert focused.accepts("en")
     assert not focused.accepts("en-GB")
Example #6
0
 def testParsingHorrorShowAll(self):
     liberal = LanguageAcceptor("*")
     assert liberal.accepts("en-US")
     assert liberal.accepts("anything-anywhere")