def test_redis_not_used_by_arg(self, settings): settings.REDIS_LOG_POSTCODE = True postcode = {"postcode": "TE1 1ST"} log_postcode(log_dict=postcode, blocking=True) LoggedPostcode.objects.create.assert_called_once_with(**postcode) redis.Redis.assert_not_called()
def test_redis_used(self, settings): settings.REDIS_LOG_POSTCODE = True postcode = {"postcode": "TE1 1ST"} log_postcode(log_dict=postcode) LoggedPostcode.objects.create.assert_not_called() redis.Redis.assert_called_once() redis.Redis.return_value.zadd.assert_called_once()
def log_postcode(self, postcode): kwargs = {"postcode": postcode} kwargs.update(self.request.session["utm_data"]) log_postcode(kwargs)
def log_postcode(self, postcode): kwargs = { 'postcode': postcode, } kwargs.update(self.request.session['utm_data']) log_postcode(kwargs)