mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-16 00:09:05 +00:00
Fix RFC822 filters + More tests (#257)
* Make rfc822 filters compatible with Windows systems. .strftime() is relative to the system it's being run on. UNIX has '%s' for seconds since the EPOCH, Windows doesn't (ValueError). Solution: use .timestamp() to achieve the same result on both platforms. This also allows us to drop the float() around it, since it returns a float. * Start testing filters * Add placeholders for more tests * Make 'tests' folder a Python package Now you can run tests with just `pytest tests` * Update readme and travis config * Test timesince() * Update and organize .gitignore Deleted: (nothing) Added: Coverage files, .idea\ * Test filter_truthy, category_name * Tests for backend.py * Tests for bencode.py * Move (empty) test_models.py to tests package * Tests for utils.py * Fixes for flattenDict * Change name to `flatten_dict` * `newkey` was assigned but never used * Add a helper class for testing * Show coverage on Travis (only Travis for now...) * Remove IDE * Use correct assert functions * Update README.md
This commit is contained in:
36
tests/__init__.py
Normal file
36
tests/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
""" Sets up helper class for testing """
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from nyaa import app
|
||||
|
||||
USE_MYSQL = True
|
||||
|
||||
|
||||
class NyaaTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
app.config['TESTING'] = True
|
||||
cls.app_context = app.app_context()
|
||||
|
||||
# Use a seperate database for testing
|
||||
# if USE_MYSQL:
|
||||
# cls.db_name = 'nyaav2_tests'
|
||||
# db_uri = 'mysql://root:@localhost/{}?charset=utf8mb4'.format(cls.db_name)
|
||||
# else:
|
||||
# cls.db_name = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'test.db')
|
||||
# db_uri = 'sqlite:///{}?check_same_thread=False'.format(cls.db_name)
|
||||
|
||||
# if not os.environ.get('TRAVIS'): # Travis doesn't need a seperate DB
|
||||
# app.config['USE_MYSQL'] = USE_MYSQL
|
||||
# app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
|
||||
|
||||
with cls.app_context:
|
||||
cls.app = app.test_client()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
with cls.app_context:
|
||||
pass
|
||||
Reference in New Issue
Block a user