def test_deliberate_lookup_fail(self): """ Fail on slug lookup. """ query = "s=google-phone2" request = self.req_factory.request(QUERY_STRING=query) # Correct config, we're testing failed # slug lookup not the key here. config = {'get_key': 's'} test = QueryStringTest(config) match = test.test(request) assert match is None
def test_simple_lookup(self): """ Given a query string containing the key s; which is the one we're meant to check (specified in the config dictionary), this will return the appropriate test match. """ query = "s=google-phone&something=234" request = self.req_factory.request(QUERY_STRING=query) config = {'get_key': 's'} test = QueryStringTest(config) match = test.test(request) assert match == self.querystring_test1
def test_deliberate_fail_due_to_wrong_key(self): """ Correct slug value lookup but on the wrong key, we'll change the config dict here and try again to make sure it passes with the correct get_key value. """ query = "correct=google-phone" request = self.req_factory.request(QUERY_STRING=query) # Deliberately non-matching config dict config = {'get_key': 'incorrect'} test = QueryStringTest(config) match = test.test(request) assert match is None # Fix the config dict and try again with same query string. config['get_key'] = 'correct' test = QueryStringTest(config) match = test.test(request) assert match == self.querystring_test1