Example #1
0
    def test_cache_request_user_present(self, engine_mock):
        from nefertari.authentication import models

        model_cls = Mock()
        model_cls.pk_field.return_value = "myid"
        request = Mock(_user=Mock(myid=1))
        models.cache_request_user(model_cls, request, 1)
        assert not model_cls.get_item.called
Example #2
0
    def test_cache_request_user_wrong_id(self, engine_mock):
        from nefertari.authentication import models

        model_cls = Mock()
        model_cls.pk_field.return_value = "myid"
        request = Mock(_user=Mock(myid=4))
        models.cache_request_user(model_cls, request, 1)
        model_cls.get_item.assert_called_once_with(myid=1)
        assert request._user == model_cls.get_item()