diff --git a/.gitignore b/.gitignore index c20e862..7190950 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.swp *.pyc +*.egg-info/ +*.eggs .idea/ __pycache__/ last_mention @@ -17,4 +19,3 @@ include/ lib/ share/ local/ -venv/ diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b7e4789 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[aliases] +test=pytest diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..483bef3 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +from setuptools import setup +import sys +import os + +PACKAGE_NAME = "ticketfrei" + +sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), PACKAGE_NAME)) + +setup( + name=PACKAGE_NAME, + version='', + packages=[ + PACKAGE_NAME + ], + url='https://github.com/ticketfrei/ticketfrei', + license='ISC', + author='', + author_email='', + description='', + setup_requires=[ + 'pytest-runner', + ], + install_requires=[ + 'bottle', + 'gitpython', + 'pyjwt', + 'Markdown', + 'Mastodon.py', + 'pylibscrypt', + 'pytoml', + 'tweepy', + 'twx', + ], + tests_require=[ + 'pytest', + ], +) diff --git a/template/login.tpl b/template/login.tpl deleted file mode 100644 index 6d1e3d9..0000000 --- a/template/login.tpl +++ /dev/null @@ -1,2 +0,0 @@ -% rebase('template/wrapper.tpl', title='Login') -% include('template/login-plain.tpl') diff --git a/bots/twitterDMs/settings.tpl b/ticketfrei/__init__.py similarity index 100% rename from bots/twitterDMs/settings.tpl rename to ticketfrei/__init__.py diff --git a/active_bots/__init__.py b/ticketfrei/active_bots/__init__.py similarity index 100% rename from active_bots/__init__.py rename to ticketfrei/active_bots/__init__.py diff --git a/active_bots/mailbot.py b/ticketfrei/active_bots/mailbot.py similarity index 100% rename from active_bots/mailbot.py rename to ticketfrei/active_bots/mailbot.py diff --git a/active_bots/mastodonbot.py b/ticketfrei/active_bots/mastodonbot.py similarity index 100% rename from active_bots/mastodonbot.py rename to ticketfrei/active_bots/mastodonbot.py diff --git a/active_bots/telegrambot.py b/ticketfrei/active_bots/telegrambot.py similarity index 100% rename from active_bots/telegrambot.py rename to ticketfrei/active_bots/telegrambot.py diff --git a/active_bots/twitterDMs.py b/ticketfrei/active_bots/twitterDMs.py similarity index 100% rename from active_bots/twitterDMs.py rename to ticketfrei/active_bots/twitterDMs.py diff --git a/active_bots/twitterbot.py b/ticketfrei/active_bots/twitterbot.py similarity index 100% rename from active_bots/twitterbot.py rename to ticketfrei/active_bots/twitterbot.py diff --git a/backend.py b/ticketfrei/backend.py similarity index 95% rename from backend.py rename to ticketfrei/backend.py index fd18aee..0286f77 100755 --- a/backend.py +++ b/ticketfrei/backend.py @@ -17,7 +17,7 @@ def shutdown(): if __name__ == '__main__': logger = logging.getLogger() - fh = logging.FileHandler('/var/log/ticketfrei/backend.log') + fh = logging.FileHandler(config["log"]["log_backend"]) fh.setLevel(logging.DEBUG) logger.addHandler(fh) diff --git a/bot.py b/ticketfrei/bot.py similarity index 100% rename from bot.py rename to ticketfrei/bot.py diff --git a/bots/mail/settings.tpl b/ticketfrei/bots/mail/settings.tpl similarity index 100% rename from bots/mail/settings.tpl rename to ticketfrei/bots/mail/settings.tpl diff --git a/bots/mastodon/settings.tpl b/ticketfrei/bots/mastodon/settings.tpl similarity index 100% rename from bots/mastodon/settings.tpl rename to ticketfrei/bots/mastodon/settings.tpl diff --git a/bots/telegram/settings.tpl b/ticketfrei/bots/telegram/settings.tpl similarity index 100% rename from bots/telegram/settings.tpl rename to ticketfrei/bots/telegram/settings.tpl diff --git a/bots/twitter/settings.tpl b/ticketfrei/bots/twitter/settings.tpl similarity index 100% rename from bots/twitter/settings.tpl rename to ticketfrei/bots/twitter/settings.tpl diff --git a/ticketfrei/bots/twitterDMs/settings.tpl b/ticketfrei/bots/twitterDMs/settings.tpl new file mode 100644 index 0000000..e69de29 diff --git a/config.py b/ticketfrei/config.py similarity index 71% rename from config.py rename to ticketfrei/config.py index bc7baaf..9c20c3c 100755 --- a/config.py +++ b/ticketfrei/config.py @@ -1,6 +1,10 @@ import pytoml as toml import os +ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) +TEMPLATE_DIR = os.path.join(ROOT_DIR, 'template', '') +STATIC_DIR = os.path.join(ROOT_DIR, 'static', '') +BOT_DIR = os.path.join(ROOT_DIR, 'bots') def load_env(): """ @@ -9,7 +13,7 @@ def load_env(): :return: config dictionary of dictionaries. """ - with open('config.toml.example') as defaultconf: + with open(os.path.join(ROOT_DIR, 'config.toml.example')) as defaultconf: configdict = toml.load(defaultconf) try: @@ -54,12 +58,24 @@ def load_env(): except KeyError: pass + try: + if os.environ['LOG_FRONTEND'] != "": + configdict['log']['log_frontend'] = os.environ['LOG_FRONTEND'] + except KeyError: + pass + + try: + if os.environ['LOG_BACKEND'] != "": + configdict['log']['log_backend'] = os.environ['LOG_BACKEND'] + except KeyError: + pass + return configdict # read config in TOML format (https://github.com/toml-lang/toml#toml) try: - with open('config.toml') as configfile: + with open(os.path.join(ROOT_DIR, 'config.toml')) as configfile: config = toml.load(configfile) except FileNotFoundError: config = load_env() diff --git a/config.toml.example b/ticketfrei/config.toml.example similarity index 75% rename from config.toml.example rename to ticketfrei/config.toml.example index eb519db..ee5282a 100644 --- a/config.toml.example +++ b/ticketfrei/config.toml.example @@ -11,6 +11,11 @@ contact = "b3yond@riseup.net" [mail] mbox_user = "root" +aliases_path = "/etc/aliases" [database] db_path = "/var/ticketfrei/db.sqlite" + +[log] +log_frontend = "/var/ticketfrei/frontend.log" +log_backend = "/var/log/ticketfrei/backend.log" diff --git a/db.py b/ticketfrei/db.py similarity index 99% rename from db.py rename to ticketfrei/db.py index 61100ae..3b3acfb 100644 --- a/db.py +++ b/ticketfrei/db.py @@ -243,7 +243,7 @@ u\d\d?""" (uid, "bastard")) else: uid = json['uid'] - with open("/etc/aliases", "a+") as f: + with open(config['mail']['aliases_path'], "a+") as f: f.write(city + ": " + config["mail"]["mbox_user"] + "\n") self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);", (uid, json['email'])) diff --git a/frontend.py b/ticketfrei/frontend.py similarity index 90% rename from frontend.py rename to ticketfrei/frontend.py index 38354a6..52ee5e1 100755 --- a/frontend.py +++ b/ticketfrei/frontend.py @@ -2,7 +2,7 @@ import bottle from os import listdir, path from bottle import get, post, redirect, request, response, view -from config import config +from config import config, STATIC_DIR, TEMPLATE_DIR from db import db import logging import tweepy @@ -19,13 +19,13 @@ def url(route): @get('/') -@view('template/propaganda.tpl') +@view('propaganda.tpl') def propaganda(): pass @post('/register') -@view('template/register.tpl') +@view('register.tpl') def register_post(): try: email = request.forms['email'] @@ -55,7 +55,7 @@ def register_post(): @get('/confirm//') -@view('template/propaganda.tpl') +@view('propaganda.tpl') def confirm(city, token): # check whether city already exists if db.by_city(city): @@ -76,7 +76,7 @@ def version(): @post('/login') -@view('template/login.tpl') +@view('login.tpl') def login_post(): # check login try: @@ -95,14 +95,14 @@ def city_page(city, info=None): citydict = db.user_facing_properties(city) if citydict is not None: citydict['info'] = info - return bottle.template('template/city.tpl', **citydict) - return bottle.template('template/propaganda.tpl', + return bottle.template('city.tpl', **citydict) + return bottle.template('propaganda.tpl', **dict(info='There is no Ticketfrei bot in your city' ' yet. Create one yourself!')) @get('/city/mail/') -@view('template/mail.tpl') +@view('mail.tpl') def display_mail_page(city): user = db.by_city(city) return user.state() @@ -139,34 +139,34 @@ def unsubscribe(token): @get('/settings') -@view('template/settings.tpl') +@view('settings.tpl') def settings(user): return user.state() @post('/settings/markdown') -@view('template/settings.tpl') +@view('settings.tpl') def update_markdown(user): user.set_markdown(request.forms['markdown']) return user.state() @post('/settings/mail_md') -@view('template/settings.tpl') +@view('settings.tpl') def update_mail_md(user): user.set_mail_md(request.forms['mail_md']) return user.state() @post('/settings/goodlist') -@view('template/settings.tpl') +@view('settings.tpl') def update_trigger_patterns(user): user.set_trigger_words(request.forms['goodlist']) return user.state() @post('/settings/blocklist') -@view('template/settings.tpl') +@view('settings.tpl') def update_badwords(user): user.set_badwords(request.forms['blocklist']) return user.state() @@ -187,12 +187,12 @@ def register_telegram(user): @get('/static/') def static(filename): - return bottle.static_file(filename, root='static') + return bottle.static_file(filename, root=STATIC_DIR) - -@get('/guides/') -def guides(filename): - return bottle.static_file(filename, root='guides') +# IS THIS USED? +#@get('/guides/') +#def guides(filename): +# return bottle.static_file(filename, root='guides') @get('/logout/') @@ -265,14 +265,16 @@ def login_mastodon(user): logger = logging.getLogger() -fh = logging.FileHandler('/var/log/ticketfrei/error.log') +fh = logging.FileHandler(config['log']['log_frontend']) fh.setLevel(logging.DEBUG) logger.addHandler(fh) +# TODO change TEMPLATE_PATH to BOTS_DIR after refactoring +bottle.TEMPLATE_PATH.insert(0, TEMPLATE_DIR) application = bottle.default_app() bottle.install(SessionPlugin('/')) if __name__ == '__main__': - bottle.run(host="0.0.0.0", port=config["web"]["port"]) + bottle.run(host=config["web"]["host"], port=config["web"]["port"]) else: application.catchall = False diff --git a/report.py b/ticketfrei/report.py similarity index 100% rename from report.py rename to ticketfrei/report.py diff --git a/sendmail.py b/ticketfrei/sendmail.py similarity index 100% rename from sendmail.py rename to ticketfrei/sendmail.py diff --git a/session.py b/ticketfrei/session.py similarity index 100% rename from session.py rename to ticketfrei/session.py diff --git a/static/bot.html b/ticketfrei/static/bot.html similarity index 100% rename from static/bot.html rename to ticketfrei/static/bot.html diff --git a/static/css/style.css b/ticketfrei/static/css/style.css similarity index 100% rename from static/css/style.css rename to ticketfrei/static/css/style.css diff --git a/static/img/ticketfrei-og-image.jpg b/ticketfrei/static/img/ticketfrei-og-image.jpg similarity index 100% rename from static/img/ticketfrei-og-image.jpg rename to ticketfrei/static/img/ticketfrei-og-image.jpg diff --git a/static/img/ticketfrei_logo.png b/ticketfrei/static/img/ticketfrei_logo.png similarity index 100% rename from static/img/ticketfrei_logo.png rename to ticketfrei/static/img/ticketfrei_logo.png diff --git a/static/index.html b/ticketfrei/static/index.html similarity index 100% rename from static/index.html rename to ticketfrei/static/index.html diff --git a/static/jquery-ui-1.12.1/AUTHORS.txt b/ticketfrei/static/jquery-ui-1.12.1/AUTHORS.txt similarity index 100% rename from static/jquery-ui-1.12.1/AUTHORS.txt rename to ticketfrei/static/jquery-ui-1.12.1/AUTHORS.txt diff --git a/static/jquery-ui-1.12.1/LICENSE.txt b/ticketfrei/static/jquery-ui-1.12.1/LICENSE.txt similarity index 100% rename from static/jquery-ui-1.12.1/LICENSE.txt rename to ticketfrei/static/jquery-ui-1.12.1/LICENSE.txt diff --git a/static/jquery-ui-1.12.1/external/jquery/jquery.js b/ticketfrei/static/jquery-ui-1.12.1/external/jquery/jquery.js similarity index 100% rename from static/jquery-ui-1.12.1/external/jquery/jquery.js rename to ticketfrei/static/jquery-ui-1.12.1/external/jquery/jquery.js diff --git a/static/jquery-ui-1.12.1/images/ui-icons_444444_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_444444_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_444444_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_444444_256x240.png diff --git a/static/jquery-ui-1.12.1/images/ui-icons_555555_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_555555_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_555555_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_555555_256x240.png diff --git a/static/jquery-ui-1.12.1/images/ui-icons_777620_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_777620_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_777620_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_777620_256x240.png diff --git a/static/jquery-ui-1.12.1/images/ui-icons_777777_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_777777_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_777777_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_777777_256x240.png diff --git a/static/jquery-ui-1.12.1/images/ui-icons_cc0000_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_cc0000_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_cc0000_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_cc0000_256x240.png diff --git a/static/jquery-ui-1.12.1/images/ui-icons_ffffff_256x240.png b/ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_ffffff_256x240.png similarity index 100% rename from static/jquery-ui-1.12.1/images/ui-icons_ffffff_256x240.png rename to ticketfrei/static/jquery-ui-1.12.1/images/ui-icons_ffffff_256x240.png diff --git a/static/jquery-ui-1.12.1/index.html b/ticketfrei/static/jquery-ui-1.12.1/index.html similarity index 100% rename from static/jquery-ui-1.12.1/index.html rename to ticketfrei/static/jquery-ui-1.12.1/index.html diff --git a/static/jquery-ui-1.12.1/jquery-ui.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.css diff --git a/static/jquery-ui-1.12.1/jquery-ui.js b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.js similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.js rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.js diff --git a/static/jquery-ui-1.12.1/jquery-ui.min.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.min.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.min.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.min.css diff --git a/static/jquery-ui-1.12.1/jquery-ui.min.js b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.min.js similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.min.js rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.min.js diff --git a/static/jquery-ui-1.12.1/jquery-ui.structure.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.structure.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.structure.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.structure.css diff --git a/static/jquery-ui-1.12.1/jquery-ui.structure.min.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.structure.min.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.structure.min.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.structure.min.css diff --git a/static/jquery-ui-1.12.1/jquery-ui.theme.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.theme.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.theme.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.theme.css diff --git a/static/jquery-ui-1.12.1/jquery-ui.theme.min.css b/ticketfrei/static/jquery-ui-1.12.1/jquery-ui.theme.min.css similarity index 100% rename from static/jquery-ui-1.12.1/jquery-ui.theme.min.css rename to ticketfrei/static/jquery-ui-1.12.1/jquery-ui.theme.min.css diff --git a/static/jquery-ui-1.12.1/package.json b/ticketfrei/static/jquery-ui-1.12.1/package.json similarity index 100% rename from static/jquery-ui-1.12.1/package.json rename to ticketfrei/static/jquery-ui-1.12.1/package.json diff --git a/static/js/functions.js b/ticketfrei/static/js/functions.js similarity index 100% rename from static/js/functions.js rename to ticketfrei/static/js/functions.js diff --git a/static/js/jquery-3.3.1.min.js b/ticketfrei/static/js/jquery-3.3.1.min.js similarity index 100% rename from static/js/jquery-3.3.1.min.js rename to ticketfrei/static/js/jquery-3.3.1.min.js diff --git a/static/register.html b/ticketfrei/static/register.html similarity index 100% rename from static/register.html rename to ticketfrei/static/register.html diff --git a/template/city.tpl b/ticketfrei/template/city.tpl similarity index 90% rename from template/city.tpl rename to ticketfrei/template/city.tpl index 5613168..feba2ae 100644 --- a/template/city.tpl +++ b/ticketfrei/template/city.tpl @@ -1,4 +1,4 @@ -% rebase('template/wrapper.tpl') +% rebase('wrapper.tpl') <% import markdown as md diff --git a/template/login-plain.tpl b/ticketfrei/template/login-plain.tpl similarity index 100% rename from template/login-plain.tpl rename to ticketfrei/template/login-plain.tpl diff --git a/ticketfrei/template/login.tpl b/ticketfrei/template/login.tpl new file mode 100644 index 0000000..bbb5406 --- /dev/null +++ b/ticketfrei/template/login.tpl @@ -0,0 +1,2 @@ +% rebase('wrapper.tpl', title='Login') +% include('login-plain.tpl') diff --git a/template/mail.tpl b/ticketfrei/template/mail.tpl similarity index 92% rename from template/mail.tpl rename to ticketfrei/template/mail.tpl index 58b58e9..77f81a4 100644 --- a/template/mail.tpl +++ b/ticketfrei/template/mail.tpl @@ -1,4 +1,4 @@ -% rebase('template/wrapper.tpl') +% rebase('wrapper.tpl') <% import markdown as md diff --git a/template/propaganda.tpl b/ticketfrei/template/propaganda.tpl similarity index 95% rename from template/propaganda.tpl rename to ticketfrei/template/propaganda.tpl index d8e013f..20f8244 100644 --- a/template/propaganda.tpl +++ b/ticketfrei/template/propaganda.tpl @@ -1,4 +1,4 @@ -% rebase('template/wrapper.tpl') +% rebase('wrapper.tpl') % if defined('info'):
@@ -7,7 +7,7 @@

% end -% include('template/login-plain.tpl') +% include('login-plain.tpl')

Features

Don't pay for public transport. Instead, warn each other @@ -45,7 +45,7 @@ share it with us, so others can use it, too! -% include('template/register-plain.tpl') +% include('register-plain.tpl')

Our Mission

Public transportation is meant to provide an easy and diff --git a/template/register-plain.tpl b/ticketfrei/template/register-plain.tpl similarity index 100% rename from template/register-plain.tpl rename to ticketfrei/template/register-plain.tpl diff --git a/template/register.tpl b/ticketfrei/template/register.tpl similarity index 73% rename from template/register.tpl rename to ticketfrei/template/register.tpl index 43b9c08..24ff577 100644 --- a/template/register.tpl +++ b/ticketfrei/template/register.tpl @@ -1,4 +1,4 @@ -% rebase('template/wrapper.tpl', title='Register') +% rebase('wrapper.tpl', title='Register') % if defined('info'):

@@ -6,5 +6,5 @@
% else: -% include('template/register-plain.tpl') +% include('register-plain.tpl') % end diff --git a/template/settings.tpl b/ticketfrei/template/settings.tpl similarity index 94% rename from template/settings.tpl rename to ticketfrei/template/settings.tpl index 49baacd..995ac24 100644 --- a/template/settings.tpl +++ b/ticketfrei/template/settings.tpl @@ -1,4 +1,4 @@ -% rebase('template/wrapper.tpl') +% rebase('wrapper.tpl') % if enabled: @@ -9,11 +9,12 @@ <% # import all the settings templates from bots/*/settings.tpl +from config import BOT_DIR import os -bots = os.listdir('bots') +bots = os.listdir(BOT_DIR) for bot in bots: - include('bots/' + bot + '/settings.tpl', csrf=csrf, city=city) + include(os.path.join(BOT_DIR, bot, 'settings.tpl'), csrf=csrf, city=city) end %> diff --git a/template/wrapper.tpl b/ticketfrei/template/wrapper.tpl similarity index 100% rename from template/wrapper.tpl rename to ticketfrei/template/wrapper.tpl diff --git a/ticketfrei/tests/configs/webapptestconfig.toml b/ticketfrei/tests/configs/webapptestconfig.toml new file mode 100644 index 0000000..ff54708 --- /dev/null +++ b/ticketfrei/tests/configs/webapptestconfig.toml @@ -0,0 +1,20 @@ +[twitter] +# You get those keys when you follow these steps: +# https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens +consumer_key = "your_consumer_key" +consumer_secret = "your_consumer_secret" + +[web] +host = "0.0.0.0" # will be used by bottle as a host. +port = 80 +contact = "b3yond@riseup.net" + +[mail] +mbox_user = "root" + +[database] +db_path = "/var/ticketfrei/db.sqlite" + +[log] +log_frontend = "/var/ticketfrei/frontend.log" +log_backend = "/var/log/ticketfrei/backend.log" diff --git a/ticketfrei/tests/webapptests/test_login.py b/ticketfrei/tests/webapptests/test_login.py new file mode 100644 index 0000000..3f9117f --- /dev/null +++ b/ticketfrei/tests/webapptests/test_login.py @@ -0,0 +1,23 @@ +from webtest import TestApp +import unittest +import frontend + +app = TestApp(frontend.application) + +class TestLogin(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_login_not_registered(self): + request = app.post('/login', {'email': '', 'pass': ''}, expect_errors=True) + self.assertEqual(401, request.status_code) + + def test_login_registered(self): + request = app.post('/register', {'email': 'foo@abc.de', 'pass': 'bar', 'pass-repeat': 'bar', 'city': 'testcity'}, expect_errors=True) + request = app.post('/login', {'email': 'foor@abc.de', 'pass': 'bar'}, expect_errors=False) + self.assertEqual(200, request.status_code) + diff --git a/ticketfrei/tests/webapptests/test_logout.py b/ticketfrei/tests/webapptests/test_logout.py new file mode 100644 index 0000000..e69de29 diff --git a/ticketfrei/tests/webapptests/test_mailhandling.py b/ticketfrei/tests/webapptests/test_mailhandling.py new file mode 100644 index 0000000..e69de29 diff --git a/ticketfrei/tests/webapptests/test_register.py b/ticketfrei/tests/webapptests/test_register.py new file mode 100644 index 0000000..bc88bb2 --- /dev/null +++ b/ticketfrei/tests/webapptests/test_register.py @@ -0,0 +1,16 @@ +from webtest import TestApp +import unittest +import frontend + +app = TestApp(frontend.application) + +class TestRegister(unittest.TestCase): + + def test_register(self): + request = app.post('/register', {'email': 'foo@abc.de', 'pass': 'bar', 'pass-repeat': 'bar', 'city': 'testcity'}, expect_errors=True) + self.assertEqual(200, request.status_code) + + def test_getRoot(self): + request = app.get('/') + self.assertEqual(200, request.status_code) + diff --git a/ticketfrei/tests/webapptests/test_settings.py b/ticketfrei/tests/webapptests/test_settings.py new file mode 100644 index 0000000..e69de29 diff --git a/ticketfrei/tests/webapptests/test_statics.py b/ticketfrei/tests/webapptests/test_statics.py new file mode 100644 index 0000000..e69de29 diff --git a/user.py b/ticketfrei/user.py similarity index 100% rename from user.py rename to ticketfrei/user.py diff --git a/wsgi.py b/ticketfrei/wsgi.py similarity index 100% rename from wsgi.py rename to ticketfrei/wsgi.py