feat: add basic support for wutta-continuum
and i mean *basic* - so far.. eventually will expose version history for viewing etc. unfortunately got carried away and reorganized the api docs a little while i was at it..
This commit is contained in:
parent
24f5ee1dcc
commit
71728718d8
53 changed files with 308 additions and 76 deletions
0
tests/db/__init__.py
Normal file
0
tests/db/__init__.py
Normal file
38
tests/db/test_continuum.py
Normal file
38
tests/db/test_continuum.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.util import WebTestCase
|
||||
|
||||
from wuttaweb.db import continuum as mod
|
||||
|
||||
|
||||
class TestWuttaWebContinuumPlugin(WebTestCase):
|
||||
|
||||
def setUp(self):
|
||||
if not hasattr(mod, 'WuttaWebContinuumPlugin'):
|
||||
pytest.skip("test not relevant without sqlalchemy-continuum")
|
||||
self.setup_web()
|
||||
|
||||
def make_plugin(self):
|
||||
return mod.WuttaWebContinuumPlugin()
|
||||
|
||||
def test_get_remote_addr(self):
|
||||
plugin = self.make_plugin()
|
||||
|
||||
with patch.object(mod, 'get_current_request', return_value=None):
|
||||
self.assertIsNone(plugin.get_remote_addr(None, self.session))
|
||||
|
||||
self.request.client_addr = '127.0.0.1'
|
||||
self.assertEqual(plugin.get_remote_addr(None, self.session), '127.0.0.1')
|
||||
|
||||
def test_get_user_id(self):
|
||||
plugin = self.make_plugin()
|
||||
|
||||
with patch.object(mod, 'get_current_request', return_value=None):
|
||||
self.assertIsNone(plugin.get_user_id(None, self.session))
|
||||
|
||||
self.request.user = MagicMock(uuid='some-random-uuid')
|
||||
self.assertEqual(plugin.get_user_id(None, self.session), 'some-random-uuid')
|
Loading…
Add table
Add a link
Reference in a new issue