2019-08-30 00:37:39 +00:00
|
|
|
from unittest.mock import patch
|
|
|
|
import sys, os
|
|
|
|
sys.path.append(".")
|
2019-11-21 09:26:23 +00:00
|
|
|
sys.path.append("src/")
|
2019-08-30 00:37:39 +00:00
|
|
|
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
|
2020-02-05 07:53:14 +00:00
|
|
|
from utils import createdirs
|
2019-08-30 00:37:39 +00:00
|
|
|
from onionrcommands import parser
|
2020-02-05 07:53:14 +00:00
|
|
|
import onionrsetup as setup
|
|
|
|
from netcontroller.torcontrol import customtorrc
|
2019-08-30 00:37:39 +00:00
|
|
|
class OnionrTests(unittest.TestCase):
|
|
|
|
def test_no_command(self):
|
|
|
|
testargs = ["onionr.py"]
|
|
|
|
with patch.object(sys, 'argv', testargs):
|
|
|
|
parser.register()
|
|
|
|
def test_version_command(self):
|
|
|
|
testargs = ["onionr.py", "version"]
|
|
|
|
with patch.object(sys, 'argv', testargs):
|
|
|
|
parser.register()
|
2020-02-05 07:49:24 +00:00
|
|
|
def test_site_list(self):
|
2020-02-05 07:53:14 +00:00
|
|
|
createdirs.create_dirs()
|
|
|
|
setup.setup_config()
|
2020-02-05 07:49:24 +00:00
|
|
|
testargs = ["onionr.py", "list-sites"]
|
|
|
|
with patch.object(sys, 'argv', testargs):
|
|
|
|
parser.register()
|
2019-08-30 00:37:39 +00:00
|
|
|
|
2019-09-13 02:22:25 +00:00
|
|
|
unittest.main()
|