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")
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")
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")
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")
def testParsingOneType(self): focused = LanguageAcceptor("en-US") assert focused.accepts("en-US") assert focused.accepts("en") assert not focused.accepts("en-GB")
def testParsingHorrorShowAll(self): liberal = LanguageAcceptor("*") assert liberal.accepts("en-US") assert liberal.accepts("anything-anywhere")