This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
auf-auf-django-secretquestions/secretquestions/tests/common.py

41 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
from secretquestions.models import Question, Answer, crypt_answer
class SecretQuestionTest(TestCase):
client = Client()
username = 'paul'
password = 'lemay'
def setUp(self):
self.create_user()
self.create_questions()
def create_user(self):
self.user = User.objects.create(username=self.username)
self.user.set_password(self.password)
self.user.save()
def create_questions(self):
self.question1 = Question.objects.create(text="question1")
self.question1.save()
self.question2 = Question.objects.create(text="question2")
self.question2.save()
def create_answers(self):
self.answer1 = Answer.objects.create(question=self.question1,
secret=crypt_answer('one'),
user=self.user)
self.answer1.save()
self.answer2 = Answer.objects.create(question=self.question2,
secret=crypt_answer('two'),
user=self.user)
self.answer2.save()