-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jackson Chadfield
committed
Jul 31, 2019
1 parent
547181f
commit 1035c00
Showing
14 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
import configparser | ||
import pathlib | ||
import unittest | ||
|
||
import OpenLearn | ||
|
||
|
||
class TestApp(unittest.TestCase): | ||
def test_version_number(self): | ||
"""Ensure the version is the same everywhere""" | ||
config_path = pathlib.Path(OpenLearn.__file__).parent.parent / "pyproject.toml" | ||
parser = configparser.ConfigParser() | ||
parser.read(config_path) | ||
version_number_config_file = parser["tool.poetry"]["version"].strip('"') | ||
self.assertEqual(version_number_config_file, OpenLearn.__version__) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import unittest | ||
from unittest import mock | ||
|
||
from OpenLearn import settings | ||
|
||
|
||
class TestSettingsUtilities(unittest.TestCase): | ||
@mock.patch.dict(os.environ, {'FLASK_ENV': 'development'}) | ||
def test_config_type_auto_resolution_development(self): | ||
self.assertIs(settings.ConfigType.Auto.config, settings.DevelopmentConfig) | ||
|
||
@mock.patch.dict(os.environ, {'FLASK_ENV': 'production'}) | ||
def test_config_type_auto_resolution_production(self): | ||
self.assertIs(settings.ConfigType.Auto.config, settings.ProductionConfig) | ||
|
||
@mock.patch.dict(os.environ, {'FLASK_ENV': 'testing'}) | ||
def test_config_type_auto_resolution_testing(self): | ||
self.assertIs(settings.ConfigType.Auto.config, settings.TestingConfig) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
|
||
import flask_login | ||
from flask import url_for | ||
from flask_testing import TestCase | ||
|
||
from OpenLearn import settings, database | ||
from OpenLearn.app import create_app | ||
from OpenLearn.extensions import db | ||
|
||
|
||
class BaseTestCase(TestCase): | ||
def create_app(self): | ||
app = create_app(config=settings.ConfigType.Testing) | ||
app.testing = True | ||
return app | ||
|
||
def setUp(self): | ||
db.create_all() | ||
self.user = database.User(username="testUser", password="password@123") | ||
|
||
def tearDown(self): | ||
db.session.remove() | ||
db.drop_all() | ||
|
||
|
||
class TestPublicView(BaseTestCase): | ||
def test_index_page(self): | ||
response = self.client.get(url_for('public.index')) | ||
self.assert200(response) | ||
self.assertTrue(flask_login.current_user.is_anonymous) | ||
self.assertTemplateUsed('index.html') | ||
|
||
def test_register_page(self): | ||
response = self.client.get(url_for('public.register')) | ||
self.assert200(response) | ||
self.assertTrue(flask_login.current_user.is_anonymous) | ||
self.assertTemplateUsed('register.html') | ||
|
||
def test_login_page(self): | ||
response = self.client.get(url_for('public.login')) | ||
self.assert200(response) | ||
self.assertTrue(flask_login.current_user.is_anonymous) | ||
self.assertTemplateUsed('login.html') |