Added site list command test

This commit is contained in:
Kevin Froman 2020-02-05 01:53:14 -06:00
parent 3456fae533
commit 938e1bddd3

View File

@ -6,7 +6,10 @@ import unittest, uuid
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR) print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR os.environ["ONIONR_HOME"] = TEST_DIR
from utils import createdirs
from onionrcommands import parser from onionrcommands import parser
import onionrsetup as setup
from netcontroller.torcontrol import customtorrc
class OnionrTests(unittest.TestCase): class OnionrTests(unittest.TestCase):
def test_no_command(self): def test_no_command(self):
testargs = ["onionr.py"] testargs = ["onionr.py"]
@ -17,6 +20,8 @@ class OnionrTests(unittest.TestCase):
with patch.object(sys, 'argv', testargs): with patch.object(sys, 'argv', testargs):
parser.register() parser.register()
def test_site_list(self): def test_site_list(self):
createdirs.create_dirs()
setup.setup_config()
testargs = ["onionr.py", "list-sites"] testargs = ["onionr.py", "list-sites"]
with patch.object(sys, 'argv', testargs): with patch.object(sys, 'argv', testargs):
parser.register() parser.register()