Created
November 29, 2022 18:22
-
-
Save sei-vsarvepalli/6a68ea6c47e1b59a147d34870a9395c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from bigvince import settings | |
from django.contrib.auth.models import User | |
from django.test import RequestFactory | |
from vince.views import TicketView | |
django.setup() | |
def test_ticket_view(ticket_id): | |
try: | |
url=f'vince/ticket/{ticket_id}/' | |
request_factory = RequestFactory() | |
my_request = request_factory.get(url) | |
my_request.user = User.objects.get(email=os.environ.get("SUPERUSER")) | |
my_request.session = {"bypass": settings.SECRET_KEY} | |
d=TicketView.as_view()(my_request,pk=ticket_id) | |
d.render() | |
f=open("/tmp/w","w") | |
f.write(d.content.decode()) | |
f.close() | |
return True | |
except Exception as err: | |
print(f"Exception when trying to run rest_pass routine {err}") | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Simple test case adoption for VINCE project to do automated testing and exception handling. You can run this from manage.py or direct as needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment