added config observers, delete plaintext blocks when plaintext storage is disabled

This commit is contained in:
Kevin Froman 2020-01-07 05:44:53 -06:00
parent 2e31155a5d
commit f78809fa2a
9 changed files with 156 additions and 116 deletions

View file

@ -3,5 +3,3 @@
Onionr has two test suites, this directory's unittests and integration tests.
In these unittests, be careful to manage import order. The test home directory environment variable needs to be set before most imports.

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import sys, os
sys.path.append(".")
sys.path.append("src/")
import unittest, uuid
import json
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR
from utils import identifyhome, createdirs
from onionrsetup import setup_config
createdirs.create_dirs()
setup_config()
import config
from coredb import blockmetadb
from onionrblocks.insert import insert_block
class TestTemplate(unittest.TestCase):
def test_plaintext_config(self):
b1 = insert_block('test block')
self.assertIn(b1, blockmetadb.get_block_list())
config.set('general.store_plaintext_blocks', False)
self.assertNotIn(b1, blockmetadb.get_block_list())
unittest.main()

25
tests/test_template.py Normal file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys, os
sys.path.append(".")
sys.path.append("src/")
import unittest, uuid
import json
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR
from utils import identifyhome, createdirs
from onionrsetup import setup_config
createdirs.create_dirs()
setup_config()
class TestTemplate(unittest.TestCase):
'''
Tests both the onionrusers class and the contactmanager (which inherits it)
'''
def test_true(self):
self.assertTrue(True)
unittest.main()