1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 03:40:00 +00:00

Add basic URL routing tests

This commit is contained in:
Nathan Yam 2017-06-07 23:32:26 +10:00 committed by Kfir Hadas
parent 80fecd5496
commit 232af1dc38
2 changed files with 56 additions and 0 deletions

View file

@ -28,11 +28,14 @@ mysqlclient==1.3.10
orderedset==2.0
packaging==16.8
passlib==1.7.1
progressbar2==3.20.0
progressbar33==2.4
py==1.4.34
pycodestyle==2.3.1
pycparser==2.17
PyMySQL==0.7.11
pyparsing==2.2.0
pytest==3.1.1
python-dateutil==2.6.0
python-editor==1.0.3
python-utils==2.1.0

53
tests/test_nyaa.py Normal file
View file

@ -0,0 +1,53 @@
import os
import unittest
import tempfile
import nyaa
class NyaaTestCase(unittest.TestCase):
def setUp(self):
self.db, nyaa.app.config['DATABASE'] = tempfile.mkstemp()
nyaa.app.config['TESTING'] = True
self.app = nyaa.app.test_client()
with nyaa.app.app_context():
nyaa.db.create_all()
def tearDown(self):
os.close(self.db)
os.unlink(nyaa.app.config['DATABASE'])
def test_empty_db(self):
rv = self.app.get('/')
assert b'Browse :: Nyaa' in rv.data
assert b'Guest' in rv.data
def test_upload_url(self):
rv = self.app.get('/upload')
assert b'Upload Torrent' in rv.data
assert b'You are not logged in, and are uploading anonymously.' in rv.data
def test_rules_url(self):
rv = self.app.get('/rules')
assert b'Site Rules' in rv.data
def test_help_url(self):
rv = self.app.get('/help')
assert b'Using the Site' in rv.data
def test_rss_url(self):
rv = self.app.get('/?page=rss')
assert b'/xmlns/nyaa' in rv.data
def test_login_url(self):
rv = self.app.get('/login')
assert b'Username or email address' in rv.data
def test_registry(self):
rv = self.app.get('/register')
assert b'Username' in rv.data
assert b'Password' in rv.data
if __name__ == '__main__':
unittest.main()