def test_check_params_mandatory_not_empty(self): event = json.loads("""{ "body":null, "queryStringParameters":{ "mandatory1":"", "mandatory2":"bar", "optional1":"baz", "extra1":"quux" } }""") req = Request(event, '0fa8fc8f-b04a-11e6-b8ed-6dda0ca82a80') (err, res) = req.get_and_check_params(['mandatory1', 'mandatory2'], ['optional1']) self.assertFalse(res) self.assertEqual('Empty or missing mandatory parameter(s): mandatory1', str(err))
def test_check_params(self): event = json.loads("""{ "body":null, "queryStringParameters":{ "mandatory1":"foo", "mandatory2":"bar", "optional1":"baz", "extra1":"quux" }, "pathParameters":null }""") req = Request(event, '0fa8fc8f-b04a-11e6-b8ed-6dda0ca82a80') (err, res) = req.get_and_check_params(['mandatory1', 'mandatory2'], ['optional1']) self.assertTrue(res) self.assertEqual(['mandatory1', 'mandatory2', 'optional1'], sorted(req.params.keys()))
def test_check_params_are_on_path(self): req = Request(self.event_params, '0fa8fc8f-b04a-11e6-b8ed-6dda0ca82a80') (err, res) = req.get_and_check_params(['mandatory1'], []) self.assertTrue(res)