added custom torrc support
This commit is contained in:
parent
15872f8f7c
commit
6b0c88aff9
5 changed files with 89 additions and 2 deletions
31
tests/test_custom_torrc.py
Normal file
31
tests/test_custom_torrc.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import sys, os
|
||||
sys.path.append(".")
|
||||
sys.path.append("src/")
|
||||
import unittest, uuid
|
||||
|
||||
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 createdirs, identifyhome
|
||||
import onionrsetup as setup
|
||||
from netcontroller import customtorrc
|
||||
createdirs.create_dirs()
|
||||
setup.setup_config()
|
||||
|
||||
class TestCustomTorrc(unittest.TestCase):
|
||||
def test_torrc_get(self):
|
||||
torrc = identifyhome.identify_home() + '/torrc-custom'
|
||||
self.assertEqual(customtorrc.get_custom_torrc(), '\n')
|
||||
with open(torrc, 'w') as torrc_file:
|
||||
torrc_file.write('test')
|
||||
self.assertEqual(customtorrc.get_custom_torrc(), '\ntest')
|
||||
os.remove(torrc)
|
||||
|
||||
def test_torrc_set(self):
|
||||
torrc = identifyhome.identify_home() + '/torrc-custom'
|
||||
customtorrc.set_custom_torrc('test2')
|
||||
with open(torrc, 'r') as torrc_file:
|
||||
self.assertEqual(torrc_file.read().splitlines()[2], 'test2')
|
||||
os.remove(torrc)
|
||||
|
||||
unittest.main()
|
|
@ -7,7 +7,7 @@ import unittest, uuid
|
|||
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 networkmerger, createdirs
|
||||
from utils import networkmerger
|
||||
from coredb import keydb
|
||||
import onionrsetup as setup
|
||||
from utils import createdirs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue