Commit 1a3ed4a7 authored by Michal Čihař's avatar Michal Čihař

Do directory setup when testing SSH handling

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 519db423
...@@ -24,6 +24,7 @@ from weblate.trans.util import add_configuration_error ...@@ -24,6 +24,7 @@ from weblate.trans.util import add_configuration_error
from weblate import appsettings from weblate import appsettings
from weblate.trans.tests import OverrideSettings from weblate.trans.tests import OverrideSettings
from weblate.trans.tests.utils import get_test_file from weblate.trans.tests.utils import get_test_file
from weblate.trans.data import check_data_writable
import os import os
...@@ -47,6 +48,7 @@ class AdminTest(ViewTestCase): ...@@ -47,6 +48,7 @@ class AdminTest(ViewTestCase):
@OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR) @OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR)
def test_ssh_generate(self): def test_ssh_generate(self):
check_data_writable()
response = self.client.get(reverse('admin-ssh')) response = self.client.get(reverse('admin-ssh'))
self.assertContains(response, 'Generate SSH key') self.assertContains(response, 'Generate SSH key')
...@@ -58,6 +60,7 @@ class AdminTest(ViewTestCase): ...@@ -58,6 +60,7 @@ class AdminTest(ViewTestCase):
@OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR) @OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR)
def test_ssh_add(self): def test_ssh_add(self):
check_data_writable()
try: try:
oldpath = os.environ['PATH'] oldpath = os.environ['PATH']
os.environ['PATH'] = ':'.join( os.environ['PATH'] = ':'.join(
......
...@@ -24,6 +24,7 @@ from django.test import TestCase ...@@ -24,6 +24,7 @@ from django.test import TestCase
from weblate.trans.ssh import get_host_keys, create_ssh_wrapper, ssh_file from weblate.trans.ssh import get_host_keys, create_ssh_wrapper, ssh_file
from weblate.trans.tests.utils import get_test_file from weblate.trans.tests.utils import get_test_file
from weblate.trans.tests import OverrideSettings from weblate.trans.tests import OverrideSettings
from weblate.trans.data import check_data_writable
from weblate import appsettings from weblate import appsettings
...@@ -36,14 +37,14 @@ class SSHTest(TestCase): ...@@ -36,14 +37,14 @@ class SSHTest(TestCase):
''' '''
@OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR) @OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR)
def test_parse(self): def test_parse(self):
tempdir = os.path.join(appsettings.DATA_DIR, 'ssh') check_data_writable()
os.makedirs(tempdir) shutil.copy(TEST_HOSTS, os.path.join(appsettings.DATA_DIR, 'ssh'))
shutil.copy(TEST_HOSTS, tempdir)
hosts = get_host_keys() hosts = get_host_keys()
self.assertEqual(len(hosts), 50) self.assertEqual(len(hosts), 50)
@OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR) @OverrideSettings(DATA_DIR=OverrideSettings.TEMP_DIR)
def test_create_ssh_wrapper(self): def test_create_ssh_wrapper(self):
check_data_writable()
filename = os.path.join( filename = os.path.join(
appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper' appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper'
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment