Skip to content

Commit 2e8da0f

Browse files
Merge branch 'predev' into env-variable
2 parents 3f4cd11 + d918ef1 commit 2e8da0f

File tree

17 files changed

+611
-25
lines changed

17 files changed

+611
-25
lines changed

Diff for: .coveragerc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[report]
2+
omit =
3+
*migrations*
4+
*/tests/*
5+
oshc/manage.py
6+
oshc/oshc/*
7+
*/admin.py

Diff for: .travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ install:
1616
- pip install coveralls
1717

1818
before_script:
19+
- export SECRET_KEY='x1-pogt0-b5owbgq0=ui02-4v)bba!bg&1m8_$)8-&13(907qf'
1920
- psql -c 'create database travis_ci_test;' -U postgres
2021
- cd oshc/
2122
- python manage.py migrate --noinput
2223
- python manage.py collectstatic --noinput
2324
- git diff-tree --no-commit-id --name-only -r $REVISION | xargs pre-commit run --files
2425

2526
script:
26-
- coverage run --source='main' manage.py test --verbosity 2
27+
- coverage run --source='.' manage.py test --verbosity 2
2728

2829
after_success:
2930
- coverage report

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ In Linux, run the `export DEBUG=True` command in the terminal.
7171
Feel free to raise and fix issues.
7272
For any questions, join #oshc-dev on Slack. Get an invite [here](https://opensourcehelp.herokuapp.com/).
7373

74-
Note : All design related tasks have reward associated with them.
74+
Note: All design related tasks have reward associated with them.

Diff for: docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = OpenBuds
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Diff for: docs/make.bat

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
set SPHINXPROJ=OpenBuds
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd

Diff for: docs/source/conf.py

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# OpenBuds documentation build configuration file, created by
5+
# sphinx-quickstart on Sun Nov 26 08:56:50 2017.
6+
#
7+
# This file is execfile()d with the current directory set to its
8+
# containing dir.
9+
#
10+
# Note that not all possible configuration values are present in this
11+
# autogenerated file.
12+
#
13+
# All configuration values have a default; values that are commented out
14+
# serve to show the default.
15+
16+
# If extensions (or modules to document with autodoc) are in another directory,
17+
# add these directories to sys.path here. If the directory is relative to the
18+
# documentation root, use os.path.abspath to make it absolute, like shown here.
19+
#
20+
# import os
21+
# import sys
22+
# sys.path.insert(0, os.path.abspath('.'))
23+
24+
25+
# -- General configuration ------------------------------------------------
26+
27+
# If your documentation needs a minimal Sphinx version, state it here.
28+
#
29+
# needs_sphinx = '1.0'
30+
31+
# Add any Sphinx extension module names here, as strings. They can be
32+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
33+
# ones.
34+
35+
from recommonmark.parser import CommonMarkParser
36+
37+
source_parsers = {
38+
'.md': CommonMarkParser,
39+
}
40+
41+
extensions = ['sphinx.ext.autodoc',
42+
'sphinx.ext.doctest',
43+
'sphinx.ext.todo',
44+
'sphinx.ext.coverage',
45+
'sphinx.ext.mathjax',
46+
'sphinx.ext.githubpages']
47+
48+
# Add any paths that contain templates here, relative to this directory.
49+
templates_path = ['_templates']
50+
51+
# The suffix(es) of source filenames.
52+
# You can specify multiple suffix as a list of string:
53+
#
54+
source_suffix = ['.rst', '.md']
55+
# source_suffix = '.rst'
56+
57+
# The master toctree document.
58+
master_doc = 'index'
59+
60+
# General information about the project.
61+
project = 'OpenBuds'
62+
copyright = '2017, OpenBuds'
63+
author = 'OpenBuds'
64+
65+
# The version info for the project you're documenting, acts as replacement for
66+
# |version| and |release|, also used in various other places throughout the
67+
# built documents.
68+
#
69+
# The short X.Y version.
70+
version = '1.0.0'
71+
# The full version, including alpha/beta/rc tags.
72+
release = 'v1.0.0'
73+
74+
# The language for content autogenerated by Sphinx. Refer to documentation
75+
# for a list of supported languages.
76+
#
77+
# This is also used if you do content translation via gettext catalogs.
78+
# Usually you set "language" from the command line for these cases.
79+
language = None
80+
81+
# List of patterns, relative to source directory, that match files and
82+
# directories to ignore when looking for source files.
83+
# This patterns also effect to html_static_path and html_extra_path
84+
exclude_patterns = []
85+
86+
# The name of the Pygments (syntax highlighting) style to use.
87+
pygments_style = 'sphinx'
88+
89+
# If true, `todo` and `todoList` produce output, else they produce nothing.
90+
todo_include_todos = True
91+
92+
93+
# -- Options for HTML output ----------------------------------------------
94+
95+
# The theme to use for HTML and HTML Help pages. See the documentation for
96+
# a list of builtin themes.
97+
#
98+
html_theme = 'alabaster'
99+
100+
# Theme options are theme-specific and customize the look and feel of a theme
101+
# further. For a list of options available for each theme, see the
102+
# documentation.
103+
#
104+
# html_theme_options = {}
105+
106+
# Add any paths that contain custom static files (such as style sheets) here,
107+
# relative to this directory. They are copied after the builtin static files,
108+
# so a file named "default.css" will overwrite the builtin "default.css".
109+
html_static_path = ['_static']
110+
111+
# Custom sidebar templates, must be a dictionary that maps document names
112+
# to template names.
113+
#
114+
# This is required for the alabaster theme
115+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
116+
html_sidebars = {
117+
'**': [
118+
'relations.html', # needs 'show_related': True theme option to display
119+
'searchbox.html',
120+
]
121+
}
122+
123+
124+
# -- Options for HTMLHelp output ------------------------------------------
125+
126+
# Output file base name for HTML help builder.
127+
htmlhelp_basename = 'OpenBudsdoc'
128+
129+
130+
# -- Options for LaTeX output ---------------------------------------------
131+
132+
latex_elements = {
133+
# The paper size ('letterpaper' or 'a4paper').
134+
#
135+
# 'papersize': 'letterpaper',
136+
137+
# The font size ('10pt', '11pt' or '12pt').
138+
#
139+
# 'pointsize': '10pt',
140+
141+
# Additional stuff for the LaTeX preamble.
142+
#
143+
# 'preamble': '',
144+
145+
# Latex figure (float) alignment
146+
#
147+
# 'figure_align': 'htbp',
148+
}
149+
150+
# Grouping the document tree into LaTeX files. List of tuples
151+
# (source start file, target name, title,
152+
# author, documentclass [howto, manual, or own class]).
153+
latex_documents = [
154+
(master_doc, 'OpenBuds.tex', 'OpenBuds Documentation',
155+
'OpenBuds', 'manual'),
156+
]
157+
158+
159+
# -- Options for manual page output ---------------------------------------
160+
161+
# One entry per manual page. List of tuples
162+
# (source start file, name, description, authors, manual section).
163+
man_pages = [
164+
(master_doc, 'openbuds', 'OpenBuds Documentation',
165+
[author], 1)
166+
]
167+
168+
169+
# -- Options for Texinfo output -------------------------------------------
170+
171+
# Grouping the document tree into Texinfo files. List of tuples
172+
# (source start file, target name, title, author,
173+
# dir menu entry, description, category)
174+
texinfo_documents = [
175+
(master_doc, 'OpenBuds', 'OpenBuds Documentation',
176+
author, 'OpenBuds', 'One line description of project.',
177+
'Miscellaneous'),
178+
]
179+
180+
181+
182+
# -- Options for Epub output ----------------------------------------------
183+
184+
# Bibliographic Dublin Core info.
185+
epub_title = project
186+
epub_author = author
187+
epub_publisher = author
188+
epub_copyright = copyright
189+
190+
# The unique identifier of the text. This can be a ISBN number
191+
# or the project homepage.
192+
#
193+
# epub_identifier = ''
194+
195+
# A unique identification for the text.
196+
#
197+
# epub_uid = ''
198+
199+
# A list of files that should not be packed into the epub file.
200+
epub_exclude_files = ['search.html']
201+
202+

Diff for: docs/source/index.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. OpenBuds documentation master file, created by
2+
sphinx-quickstart on Sun Nov 26 08:56:50 2017.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to OpenBuds's documentation!
7+
====================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

Diff for: oshc/authentication/tests.py

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.contrib.auth.models import User
5+
from django.test import TestCase
6+
from django.urls import reverse
7+
from .regbackend import EmailLoginBackend
8+
9+
10+
class LoginViewTests(TestCase):
11+
12+
def test_get_request(self):
13+
response = self.client.get(reverse("account_login"))
14+
self.assertEqual(response.status_code, 200)
15+
16+
17+
class RegisterViewTest(TestCase):
18+
19+
def test_get_request(self):
20+
response = self.client.get(reverse("account_signup"))
21+
self.assertEqual(response.status_code, 200)
22+
23+
24+
class PasswordChangeViewTest(TestCase):
25+
26+
def test_get_request(self):
27+
response = self.client.get(reverse("account_change_password"))
28+
self.assertEqual(response.status_code, 302)
29+
30+
31+
class PasswordResetViewTest(TestCase):
32+
33+
def test_get_request(self):
34+
response = self.client.get(reverse("account_reset_password"))
35+
self.assertEqual(response.status_code, 200)
36+
37+
38+
class EmailLoginBackendTests(TestCase):
39+
40+
def setUp(self):
41+
self.credentials = {
42+
'username': 'test',
43+
'email': '[email protected]',
44+
'password': 'test@123'}
45+
self.user = User.objects.create_user(**self.credentials)
46+
47+
def test_valid_username_login(self):
48+
response = self.client.login(username=self.credentials['username'],
49+
password=self.credentials['password'])
50+
self.assertTrue(response)
51+
52+
def test_invalid_username_login(self):
53+
response = self.client.login(username='invalid_username',
54+
password=self.credentials['password'])
55+
self.assertFalse(response)
56+
57+
def test_valid_email_login(self):
58+
response = self.client.login(username=self.credentials['email'],
59+
password=self.credentials['password'])
60+
self.assertTrue(response)
61+
62+
def test_invalid_email_login(self):
63+
response = self.client.login(username='invalid_email',
64+
password=self.credentials['password'])
65+
self.assertFalse(response)
66+
67+
def test_invalid_password_login(self):
68+
response = self.client.login(username=self.credentials['email'],
69+
password='incorrect_password')
70+
self.assertFalse(response)
71+
72+
def test_valid_get_user(self):
73+
backend = EmailLoginBackend()
74+
returned_user = backend.get_user(self.user.id)
75+
self.assertEqual(returned_user.id, self.user.id)
76+
77+
def test_invalid_get_user(self):
78+
backend = EmailLoginBackend()
79+
# The database has only one user. User with id=10 doesn't exists
80+
returned_user = backend.get_user(user_id=10)
81+
self.assertIsNone(returned_user)

0 commit comments

Comments
 (0)