Moved some production-path checks to the checks module, and fixed up tests which changed some settings without restoring them.
- Legacy-Id: 10808
This commit is contained in:
commit
b00b0c3db9
|
@ -67,3 +67,34 @@ def check_doc_email_aliases_exists(app_configs, **kwargs):
|
|||
|
||||
return errors
|
||||
|
||||
@checks.register('directories')
|
||||
def check_id_submission_directories(app_configs, **kwargs):
|
||||
errors = []
|
||||
for s in ("IDSUBMIT_STAGING_PATH", "IDSUBMIT_REPOSITORY_PATH", "INTERNET_DRAFT_ARCHIVE_DIR"):
|
||||
p = getattr(settings, s)
|
||||
if not os.path.exists(p):
|
||||
errors.append(checks.Critical(
|
||||
"A directory used by the ID submission tool does not exist at the path given\n"
|
||||
"in the settings file. The setting is:\n"
|
||||
" %s = %s" % (s, p),
|
||||
hint = ("Please either update the local settings to point at the correct directory,"
|
||||
"or if the setting is correct, create the directory."),
|
||||
id = "datatracker.E0006",
|
||||
))
|
||||
return errors
|
||||
|
||||
@checks.register('files')
|
||||
def check_id_submission_files(app_configs, **kwargs):
|
||||
errors = []
|
||||
for s in ("IDSUBMIT_IDNITS_BINARY", ):
|
||||
p = getattr(settings, s)
|
||||
if not os.path.exists(p):
|
||||
errors.append(checks.Critical(
|
||||
"A file used by the ID submission tool does not exist at the path given\n"
|
||||
"in the settings file. The setting is:\n"
|
||||
" %s = %s" % (s, p),
|
||||
hint = ("Please either update the local settings to point at the correct file,"
|
||||
"or if the setting is correct, make sure the file is in place and has the right permissions."),
|
||||
id = "datatracker.E0007",
|
||||
))
|
||||
return errors
|
||||
|
|
|
@ -498,6 +498,8 @@ class ResurrectTests(TestCase):
|
|||
|
||||
class ExpireIDsTests(TestCase):
|
||||
def setUp(self):
|
||||
self.saved_id_dir = settings.INTERNET_DRAFT_PATH
|
||||
self.saved_archive_dir = settings.INTERNET_DRAFT_ARCHIVE_DIR
|
||||
self.id_dir = os.path.abspath("tmp-id-dir")
|
||||
self.archive_dir = os.path.abspath("tmp-id-archive")
|
||||
if not os.path.exists(self.id_dir):
|
||||
|
@ -514,6 +516,8 @@ class ExpireIDsTests(TestCase):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.id_dir)
|
||||
shutil.rmtree(self.archive_dir)
|
||||
settings.INTERNET_DRAFT_PATH = self.saved_id_dir
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.saved_archive_dir
|
||||
|
||||
def write_draft_file(self, name, size):
|
||||
f = open(os.path.join(self.id_dir, name), 'w')
|
||||
|
|
|
@ -18,10 +18,12 @@ SECR_USER='secretary'
|
|||
|
||||
class MainTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.saved_internet_draft_path = settings.INTERNET_DRAFT_PATH
|
||||
self.repository_dir = os.path.abspath("tmp-submit-repository-dir")
|
||||
os.mkdir(self.repository_dir)
|
||||
settings.INTERNET_DRAFT_PATH = self.repository_dir
|
||||
|
||||
self.saved_internet_draft_archive_dir = settings.INTERNET_DRAFT_ARCHIVE_DIR
|
||||
self.archive_dir = os.path.abspath("tmp-submit-archive-dir")
|
||||
os.mkdir(self.archive_dir)
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.archive_dir
|
||||
|
@ -34,6 +36,8 @@ class MainTestCase(TestCase):
|
|||
shutil.rmtree(self.repository_dir)
|
||||
shutil.rmtree(self.archive_dir)
|
||||
shutil.rmtree(self.manual_dir)
|
||||
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.saved_internet_draft_archive_dir
|
||||
|
||||
def test_abstract(self):
|
||||
draft = make_test_data()
|
||||
|
|
|
@ -41,8 +41,6 @@ def archive_draft_files(filename):
|
|||
Takes a string representing the old draft filename, without extensions.
|
||||
Moves any matching files to archive directory.
|
||||
'''
|
||||
if not os.path.isdir(settings.INTERNET_DRAFT_ARCHIVE_DIR):
|
||||
raise IOError('Internet-Draft archive directory does not exist (%s)' % settings.INTERNET_DRAFT_ARCHIVE_DIR)
|
||||
files = glob.glob(os.path.join(settings.INTERNET_DRAFT_PATH,filename) + '.*')
|
||||
for file in files:
|
||||
shutil.move(file,settings.INTERNET_DRAFT_ARCHIVE_DIR)
|
||||
|
|
|
@ -118,12 +118,6 @@ class SubmissionUploadForm(forms.Form):
|
|||
if self.shutdown and not has_role(self.request.user, "Secretariat"):
|
||||
raise forms.ValidationError('The submission tool is currently shut down')
|
||||
|
||||
# sanity check that paths exist (for development servers)
|
||||
for s in ("IDSUBMIT_STAGING_PATH", "IDSUBMIT_IDNITS_BINARY",
|
||||
"IDSUBMIT_REPOSITORY_PATH", "INTERNET_DRAFT_ARCHIVE_DIR"):
|
||||
if not os.path.exists(getattr(settings, s)):
|
||||
raise forms.ValidationError('%s defined in settings.py does not exist' % s)
|
||||
|
||||
for ext in ['txt', 'pdf', 'xml', 'ps']:
|
||||
f = self.cleaned_data.get(ext, None)
|
||||
if not f:
|
||||
|
|
|
@ -24,14 +24,18 @@ from ietf.submit.models import Submission, Preapproval
|
|||
|
||||
class SubmitTests(TestCase):
|
||||
def setUp(self):
|
||||
self.saved_idsubmit_staging_path = settings.IDSUBMIT_STAGING_PATH
|
||||
self.staging_dir = os.path.abspath("tmp-submit-staging-dir")
|
||||
os.mkdir(self.staging_dir)
|
||||
settings.IDSUBMIT_STAGING_PATH = self.staging_dir
|
||||
|
||||
self.saved_internet_draft_path = settings.INTERNET_DRAFT_PATH
|
||||
self.saved_idsubmit_repository_path = settings.IDSUBMIT_REPOSITORY_PATH
|
||||
self.repository_dir = os.path.abspath("tmp-submit-repository-dir")
|
||||
os.mkdir(self.repository_dir)
|
||||
settings.INTERNET_DRAFT_PATH = settings.IDSUBMIT_REPOSITORY_PATH = self.repository_dir
|
||||
|
||||
self.saved_archive_dir = settings.INTERNET_DRAFT_ARCHIVE_DIR
|
||||
self.archive_dir = os.path.abspath("tmp-submit-archive-dir")
|
||||
os.mkdir(self.archive_dir)
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.archive_dir
|
||||
|
@ -40,6 +44,11 @@ class SubmitTests(TestCase):
|
|||
shutil.rmtree(self.staging_dir)
|
||||
shutil.rmtree(self.repository_dir)
|
||||
shutil.rmtree(self.archive_dir)
|
||||
settings.IDSUBMIT_STAGING_PATH = self.saved_idsubmit_staging_path
|
||||
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
|
||||
settings.IDSUBMIT_REPOSITORY_PATH = self.saved_idsubmit_repository_path
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.saved_archive_dir
|
||||
|
||||
|
||||
def submission_file(self, name, rev, group, format, templatename):
|
||||
# construct appropriate text draft
|
||||
|
|
|
@ -209,6 +209,8 @@ ICANN
|
|||
|
||||
class RFCSyncTests(TestCase):
|
||||
def setUp(self):
|
||||
self.save_id_dir = settings.INTERNET_DRAFT_PATH
|
||||
self.save_archive_dir = settings.INTERNET_DRAFT_ARCHIVE_DIR
|
||||
self.id_dir = os.path.abspath("tmp-id-dir")
|
||||
self.archive_dir = os.path.abspath("tmp-id-archive")
|
||||
if not os.path.exists(self.id_dir):
|
||||
|
@ -221,6 +223,8 @@ class RFCSyncTests(TestCase):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.id_dir)
|
||||
shutil.rmtree(self.archive_dir)
|
||||
settings.INTERNET_DRAFT_PATH = self.save_id_dir
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.save_archive_dir
|
||||
|
||||
def write_draft_file(self, name, size):
|
||||
with open(os.path.join(self.id_dir, name), 'w') as f:
|
||||
|
|
Loading…
Reference in a new issue