Skip to content

Instantly share code, notes, and snippets.

View Elise-Lennion's full-sized avatar

Elise Lennion Elise-Lennion

View GitHub Profile
from board.models import Question # Model class
test_question1 = Question(title='Question1',)
test_question1.id = 1
test_question1.save()
from board.models import Question # Model class
test_question1 = Question(title='Question1',)
test_question1.id = 1
test_question1.save()
from django.urls import reverse
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
def test_title_redirects_to_details(self):
self.browser.get(self.live_server_url + reverse('question-list'))
title = WebDriverWait(self.browser, 5).until(
def test_create_button(self):
self.browser.get(self.live_server_url + 'question/create/')
# Test the page
def test_Open_is_initial_active_tab(self):
self.browser.get(self.live_server_url + reverse('question-list'))
# Test the page 'question-list'
def test_Open_is_initial_active_tab(self):
self.browser.get(self.live_server_url + reverse('question-list')
# Test the url 'question-list'
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
class TestName(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.browser = webdriver.Firefox()
@classmethod
from django.test import TestCase
from django.contrib.auth.models import User
from django.contrib import auth
class FrontPageViewTest(TestCase):
@classmethod
def setUpTestData(cls):
""" Creates 1 user """
from django.contrib.auth.forms import AuthenticationForm
from django.shortcuts import render
from research.forms import UserCreateForm # Custom register form
def front_page_view(request):
if request.method == 'POST':
if 'login_form' in request.POST:
login_form = AuthenticationForm(request=request, data=request.POST)