36 lines
959 B
Python
36 lines
959 B
Python
|
"""
|
||
|
Test Slinky
|
||
|
"""
|
||
|
from typing import Any
|
||
|
from unittest import TestCase, mock
|
||
|
|
||
|
from slinky import web
|
||
|
|
||
|
@mock.patch.dict('slinky.web.cfg', {'db': 'sqlite:///tests/test.db'})
|
||
|
class TestWeb(TestCase):
|
||
|
"""
|
||
|
Class to test Slinky code
|
||
|
"""
|
||
|
|
||
|
def test_simple_redirect(self, *_: Any) -> None:
|
||
|
"""
|
||
|
Ensure simple redirect works
|
||
|
"""
|
||
|
response = web.try_path_as_shortcode('egie')
|
||
|
self.assertEqual(response.status_code, 302)
|
||
|
self.assertEqual(response.location, 'https://example.com')
|
||
|
|
||
|
def test_fixed_views(self, *_: Any) -> None:
|
||
|
"""
|
||
|
Ensure simple redirect works
|
||
|
"""
|
||
|
response = web.try_path_as_shortcode('egig')
|
||
|
self.assertEqual(response.status_code, 404)
|
||
|
|
||
|
def test_expiry(self, *_: Any) -> None:
|
||
|
"""
|
||
|
Ensure simple redirect works
|
||
|
"""
|
||
|
response = web.try_path_as_shortcode('egif')
|
||
|
self.assertEqual(response.status_code, 404)
|