def test_get_context_with_no_notify_in_session(self, super_mock): super_mock.return_value = dict(super=sentinel.super) view = UserSettingsView() view.request = Mock(session=dict()) # When getting the context data context = view.get_context_data() # Then notify is not in the context assert 'notify' not in context assert context['super'] == sentinel.super
def test_get_context_with_notify_in_session(self, super_mock): super_mock.return_value = {} # Given a request session with a notify value view = UserSettingsView() view.request = Mock(session=dict(notify=sentinel.notify)) # When getting the context data context = view.get_context_data() # Then the notify value is included in the context assert context['notify'] == sentinel.notify # and the notify value is removed from the session assert 'notify' not in view.request.session