mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-13 15:19:03 +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:
46
tests/test_backend.py
Normal file
46
tests/test_backend.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import unittest
|
||||
|
||||
from nyaa import backend
|
||||
|
||||
|
||||
class TestBackend(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_replace_utf8_values(self):
|
||||
test_dict = {
|
||||
'hash': '2346ad27d7568ba9896f1b7da6b5991251debdf2',
|
||||
'title.utf-8': '¡hola! ¿qué tal?',
|
||||
'filelist.utf-8': [
|
||||
'Español 101.mkv',
|
||||
'ру́сский 202.mp4'
|
||||
]
|
||||
}
|
||||
expected_dict = {
|
||||
'hash': '2346ad27d7568ba9896f1b7da6b5991251debdf2',
|
||||
'title': '¡hola! ¿qué tal?',
|
||||
'filelist': [
|
||||
'Español 101.mkv',
|
||||
'ру́сский 202.mp4'
|
||||
]
|
||||
}
|
||||
|
||||
self.assertTrue(backend._replace_utf8_values(test_dict))
|
||||
self.assertDictEqual(test_dict, expected_dict)
|
||||
|
||||
@unittest.skip('Not yet implemented')
|
||||
def test_handle_torrent_upload(self):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user