def test_basic(self):
        allowed = 'json', 'xml', 'form', 'text'

        self.assertEqual(negotiate.value(allowed, 'application/json'),
        'json')
        self.assertEqual(negotiate.value(allowed, 'xml'), 'xml')
        self.assertEqual(negotiate.value(allowed, 'none'), None)

        header = ','.join(('application/xbel+xml', 'text/xml', 'text/*;q=0.5','*/*; q=0.1'))
        self.assertEqual(negotiate.range(allowed, header), 'xml')

        self.assertEqual(negotiate.range(['json'], header), 'json')
Example #2
0
 def accept(self):
     if 'accept' in self:
         return self['accept']
     elif 'Accept' in self.headers:
         return negotiate.range(self['supported_types'], self.headers['Accept'])