def check(self): cases = self.expect[:] p = RequestParser(Config(), self.send()) try: [req for req in p] except Exception, inst: exp = cases.pop(0) if not issubclass(exp, Exception): raise TypeError("Test case is not an exception calss: %s" % exp) t.istype(inst, exp) return
def test_atoms_defaults(): response = Mock(status='200', response_length=1024, headers=(('Content-Type', 'application/json'), )) request = Mock(headers=(('Accept', 'application/json'), )) environ = {'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri', 'SERVER_PROTOCOL': 'HTTP/1.1'} logger = Logger(Config()) atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1)) t.istype(atoms, dict) t.eq(atoms['r'], 'GET http://my.uri HTTP/1.1') t.eq(atoms['{accept}i'], 'application/json') t.eq(atoms['{content-type}o'], 'application/json')