Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions functional_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from selenium import webdriver

browser = webdriver.Firefox(executable_path='/home/kiptoo/.local/bin/geckodriver')

# Samwel has heard about a cool new blog. He goes to
# check out its homepage

browser.get('http://0.0.0:8000')

# He notices the page header and title mention blog application.

assert 'My Blog' in browser.title

# He finds an interesting post on python
# He click it right away and starts to read it
# He finds it interesting and decides to comment on how great
# the post is
# After liking the post so much he decides to share it with his
# friend Silas
# He checks out a recommended post on Django

browser.quit()
22 changes: 22 additions & 0 deletions mysite/apps/blog/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
from django.http import HttpRequest
from django.test import TestCase
from django.urls import resolve

from .views import post_list

# Create your tests here.
class SmokeTest(TestCase):

def test_monkey_math(self):
self.assertEqual(1 + 2, 3)

class BlogHomePageTest(TestCase):

def test_blog_homepage_resolves(self):
found = resolve('/blog/')
self.assertEqual(found.func, post_list)

def test_homepage_returns_correct_html(self):
request = HttpRequest()
response = post_list(request)
html = response.content.decode('utf8')
# self.assertTrue(html.startswith('<!DOCTYPE html>'))
self.assertIn('<title>My Blog</title>', html)
# self.assertTrue(html.endswith('</html>'))
152 changes: 151 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ django = "^3.1.3"
psycopg2-binary = "^2.8.6"
django_taggit = "^1.3.0"
markdown = "^3.3.3"
selenium = "^3.141.0"
webdriver_manager = "^3.2.2"

[tool.poetry.dev-dependencies]

Expand Down