Compare commits
No commits in common. "bfaffaa9972a37e387342cf4ce68f90f03e277c7" and "1cd42eff1b9dd72c898674c678aaf6ab0b5eb0e7" have entirely different histories.
bfaffaa997
...
1cd42eff1b
|
@ -1 +0,0 @@
|
||||||
.vscode
|
|
|
@ -1,4 +0,0 @@
|
||||||
db.sqlite3
|
|
||||||
geckodriver.log
|
|
||||||
virtualenv
|
|
||||||
**__pycache__**
|
|
|
@ -1,44 +0,0 @@
|
||||||
from selenium import webdriver
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
class NewVisitorTest(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.browser = webdriver.Firefox()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.browser.quit()
|
|
||||||
|
|
||||||
def test_can_start_a_list_and_retrieve_it_later(self):
|
|
||||||
# Edith has heard about a cool new online to-do app. She goes
|
|
||||||
# to check out its homepage
|
|
||||||
self.browser.get('http://localhost:8000')
|
|
||||||
|
|
||||||
# She notices the page title and header mention to-do lists
|
|
||||||
self.assertIn('To-Do', self.browser.title)
|
|
||||||
self.fail('Finish the test!')
|
|
||||||
|
|
||||||
# She is invited to enter a to-do item straight away
|
|
||||||
|
|
||||||
# She types "Buy peacock feathers" into a text box (Edith's hobby
|
|
||||||
# is tying fly-fishing lures)
|
|
||||||
|
|
||||||
# When she hits enter, the page updates, and now the page lists
|
|
||||||
# "1: Buy peacock feathers" as an item in a to-do list
|
|
||||||
|
|
||||||
# There is still a text box inviting her to add another item. She
|
|
||||||
# enters "Use peacock feathers to make a fly" (Edith is very methodical)
|
|
||||||
|
|
||||||
# The page updates again, and now shows both items on her list
|
|
||||||
|
|
||||||
# Edith wonders whether the site will remember her list. Then she sees
|
|
||||||
# that the site has generated a unique URL for her -- there is some
|
|
||||||
# explanatory text to that effect.
|
|
||||||
|
|
||||||
# She visits that URL - her to-do list is still there.
|
|
||||||
|
|
||||||
# Satisfied, she goes back to sleep
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main(warnings='ignore')
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
|
@ -1,5 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class ListsConfig(AppConfig):
|
|
||||||
name = 'lists'
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
|
@ -1,27 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
from django.urls import resolve
|
|
||||||
from django.http import HttpRequest
|
|
||||||
|
|
||||||
from lists.views import home_page
|
|
||||||
|
|
||||||
class HomePageTest(TestCase):
|
|
||||||
|
|
||||||
def test_root_url_resolves_to_home_page_view(self):
|
|
||||||
found = resolve('/')
|
|
||||||
self.assertEqual(found.func, home_page)
|
|
||||||
|
|
||||||
def test_home_page_returns_correct_html(self):
|
|
||||||
"""
|
|
||||||
1. Create an HttpRequest object, which is what Django will see when a user's browser asks for a page
|
|
||||||
2. Pass it to `home_page` view, which gives us a response.
|
|
||||||
3. Extract `.content` of the response, which are byte value, and should be decoded into string (HTML format)
|
|
||||||
4. Check HTML starts and end with <html> tag
|
|
||||||
5. Want to find <title> tag in the middle
|
|
||||||
"""
|
|
||||||
|
|
||||||
request = HttpRequest() #1
|
|
||||||
response = home_page(request) #2
|
|
||||||
html = response.content.decode('utf8') #3
|
|
||||||
self.assertTrue(html.startswith('<html>')) #4
|
|
||||||
self.assertIn('<title>To-Do list</title>', html) #5
|
|
||||||
self.assertTrue(html.endswith('</html>')) #4
|
|
|
@ -1,8 +0,0 @@
|
||||||
from django.http.request import HttpRequest
|
|
||||||
from django.http.response import HttpResponse
|
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here
|
|
||||||
def home_page(request):
|
|
||||||
# return HttpResponse('<html><title>To-Do lists</title></html>')
|
|
||||||
return HttpResponse('<html><title>To-Do list</title></html>')
|
|
|
@ -1,22 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings")
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError:
|
|
||||||
# The above import may fail for some other reason. Ensure that the
|
|
||||||
# issue is really that Django is missing to avoid masking other
|
|
||||||
# exceptions on Python 2.
|
|
||||||
try:
|
|
||||||
import django
|
|
||||||
except ImportError:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
)
|
|
||||||
raise
|
|
||||||
execute_from_command_line(sys.argv)
|
|
|
@ -1,120 +0,0 @@
|
||||||
"""
|
|
||||||
Django settings for superlists project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 1.11.29.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/1.11/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/1.11/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = 'vpcgz!pg(&y^!0j36v)+y9ss^dvpnh!+e%s3o)m3q)71_jz!i+'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
]
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'superlists.urls'
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [],
|
|
||||||
'APP_DIRS': True,
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
WSGI_APPLICATION = 'superlists.wsgi.application'
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
|
|
@ -1,21 +0,0 @@
|
||||||
"""superlists URL Configuration
|
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
||||||
https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
|
||||||
Examples:
|
|
||||||
Function views
|
|
||||||
1. Add an import: from my_app import views
|
|
||||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
|
||||||
Class-based views
|
|
||||||
1. Add an import: from other_app.views import Home
|
|
||||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
|
||||||
Including another URLconf
|
|
||||||
1. Import the include() function: from django.conf.urls import url, include
|
|
||||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
|
||||||
"""
|
|
||||||
from django.conf.urls import url
|
|
||||||
from lists import views
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^$', views.home_page, name='home'),
|
|
||||||
]
|
|
|
@ -1,16 +0,0 @@
|
||||||
"""
|
|
||||||
WSGI config for superlists project.
|
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings")
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
|
Loading…
Reference in New Issue