2017-06-07 13:32:26 +00:00
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import tempfile
|
|
|
|
import nyaa
|
|
|
|
|
|
|
|
|
|
|
|
class NyaaTestCase(unittest.TestCase):
|
|
|
|
|
2017-08-01 18:02:08 +00:00
|
|
|
nyaa_app = nyaa.create_app('config')
|
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def setUp(self):
|
2017-08-01 18:02:08 +00:00
|
|
|
self.db, self.nyaa_app.config['DATABASE'] = tempfile.mkstemp()
|
|
|
|
self.nyaa_app.config['TESTING'] = True
|
|
|
|
self.app = self.nyaa_app.test_client()
|
|
|
|
with self.nyaa_app.app_context():
|
2017-06-07 16:32:45 +00:00
|
|
|
nyaa.db.create_all()
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def tearDown(self):
|
|
|
|
os.close(self.db)
|
2017-08-01 18:02:08 +00:00
|
|
|
os.unlink(self.nyaa_app.config['DATABASE'])
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def test_index_url(self):
|
|
|
|
rv = self.app.get('/')
|
|
|
|
assert b'Browse :: Nyaa' in rv.data
|
|
|
|
assert b'Guest' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
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
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def test_rules_url(self):
|
|
|
|
rv = self.app.get('/rules')
|
|
|
|
assert b'Site Rules' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def test_help_url(self):
|
|
|
|
rv = self.app.get('/help')
|
|
|
|
assert b'Using the Site' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def test_rss_url(self):
|
|
|
|
rv = self.app.get('/?page=rss')
|
|
|
|
assert b'/xmlns/nyaa' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-07 16:32:45 +00:00
|
|
|
def test_login_url(self):
|
|
|
|
rv = self.app.get('/login')
|
|
|
|
assert b'Username or email address' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
2017-06-08 01:04:20 +00:00
|
|
|
def test_registration_url(self):
|
2017-06-07 16:32:45 +00:00
|
|
|
rv = self.app.get('/register')
|
|
|
|
assert b'Username' in rv.data
|
|
|
|
assert b'Password' in rv.data
|
2017-06-07 13:32:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-06-07 16:32:45 +00:00
|
|
|
unittest.main()
|