This file contains hidden or 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
from selenium import webdriver | |
from django.conf import settings | |
from django.contrib.staticfiles.testing import StaticLiveServerTestCase | |
class TestFunctional(StaticLiveServerTestCase): | |
def setUp(self) -> None: | |
self.num_todos = 10 | |
self.xpath_username = "//label[@for='username']" | |
self.xpath_password = "//label[@for='password']" |
This file contains hidden or 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
from django.test import SimpleTestCase | |
from django.urls import reverse, resolve | |
from ..views import ( | |
home, | |
login, | |
logout, | |
register, | |
edit_todo, | |
create_todo, |
This file contains hidden or 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
from django.urls import path | |
from .views import ( | |
home, | |
login, | |
logout, | |
register, | |
edit_todo, | |
create_todo, | |
delete_todo, |
This file contains hidden or 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
from django.urls import reverse | |
from django.test import Client, TestCase | |
REQUIRED_FIELD_ERROR = "This field is required." | |
class TestUserView(TestCase): | |
def setUp(self): | |
self.client = Client() |
This file contains hidden or 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
from django.shortcuts import render, redirect | |
from django.contrib.auth.decorators import login_required | |
from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout | |
from .models import Todo | |
from .forms import UserForm, TodoForm | |
from .common import get_object_or_none | |
HOME_URL = "todo:home" |
This file contains hidden or 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
from django.test import TestCase | |
from django.contrib.auth.models import User | |
from todo.models import Todo | |
from ..forms import UserForm, TodoForm | |
REQUIRED_FIELD_ERROR = "This field is required." | |
This file contains hidden or 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
from django.contrib.auth.models import User | |
from django.forms import ModelForm, PasswordInput | |
from .models import Todo | |
class TodoForm(ModelForm): | |
class Meta: | |
model = Todo | |
fields = "__all__" |
This file contains hidden or 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
from django.test import TestCase | |
from django.db.utils import IntegrityError | |
from django.contrib.auth.models import User | |
from ..models import Todo | |
class TestTodoModel(TestCase): | |
def setUp(self) -> None: | |
user = User(username="testuser") |
This file contains hidden or 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
from django.test import TestCase | |
from django.contrib.auth.models import User | |
from ..models import Todo | |
class TestTodoModel(TestCase): | |
def setUp(self) -> None: | |
user = User(username="testuser") | |
user.set_password("testpassword") |
This file contains hidden or 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
from django.db import models | |
from django.contrib.auth.models import User | |
class Todo(models.Model): | |
title = models.CharField(max_length=100, null=False, blank=False, default=None) | |
description = models.TextField(null=False, blank=False, default=None) | |
completed = models.BooleanField(default=False) | |
created_at = models.DateTimeField(auto_now_add=True) | |
user = models.ForeignKey(User, on_delete=models.CASCADE) |