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:
34
tests/test_api_handler.py
Normal file
34
tests/test_api_handler.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import unittest
|
||||
import json
|
||||
|
||||
from nyaa import api_handler, models
|
||||
from tests import NyaaTestCase
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
class ApiHandlerTests(NyaaTestCase):
|
||||
|
||||
# @classmethod
|
||||
# def setUpClass(cls):
|
||||
# super(ApiHandlerTests, cls).setUpClass()
|
||||
|
||||
# @classmethod
|
||||
# def tearDownClass(cls):
|
||||
# super(ApiHandlerTests, cls).tearDownClass()
|
||||
|
||||
def test_no_authorization(self):
|
||||
""" Test that API is locked unless you're logged in """
|
||||
rv = self.app.get('/api/info/1')
|
||||
data = json.loads(rv.get_data())
|
||||
self.assertDictEqual({'errors': ['Bad authorization']}, data)
|
||||
|
||||
@unittest.skip('Not yet implemented')
|
||||
def test_bad_credentials(self):
|
||||
""" Test that API is locked unless you're logged in """
|
||||
rv = self.app.get('/api/info/1')
|
||||
data = json.loads(rv.get_data())
|
||||
self.assertDictEqual({'errors': ['Bad authorization']}, data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user