This is part of my views.py
views,py
.
.
def get(self, request, *args, **kwargs):
if request.session['from_product'] = True:
blah blah
.
.
For passing this if statement, I tried to store session data in test code like this:
class OrderViewFromProductWithLoginTest(OrderSetupTestCase):
def setUp(self):
self.login()
self.client.session['from_product'] = True
self.client.session.save()
But it doesn't work.
This is how I verified:
from django.contrib.sessions.models import Session
session = Session.objects.first()
sessoin.get_decode()
>> {'_auth_user_backend': 'django.contrib.auth.backends.ModelBackend',
'_auth_user_hash': 'ffd87a41ff1e77abcbd78724f4b5b5133c67a08f',
'_auth_user_id': '1'}
How can I implement this?