def test_source(self): req = Mock(['args', 'headers', 'values']) req.args = {'foo': 'bar'} req.headers = {'baz': 'bat'} arg = Argument('foo', location=['args']) self.assertEqual(arg.source(req), req.args) arg = Argument('foo', location=['headers']) self.assertEqual(arg.source(req), req.headers)
def test_source_default_location(self): req = Mock(['params']) req._get_child_mock = lambda **kwargs: NonCallableMock(**kwargs) arg = Argument('foo') self.assertEqual(arg.source(req), req.params)
def test_source_bad_location(self): req = Mock(['params']) arg = Argument('foo', location=['foo']) self.assertTrue(len(arg.source(req)) == 0) # yes, basically you don't find it