diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py index 3e7f9e7ba7b4c3314cd49464448aeba4e7f8783a..7921ee67fd2baab066eff1b0b233e3cdc02f3819 100644 --- a/opentech/apply/funds/tests/test_models.py +++ b/opentech/apply/funds/tests/test_models.py @@ -402,6 +402,24 @@ class TestApplicationSubmission(TestCase): # Check we saved the file somewhere beneath it self.assertIn(filename, found_files) + def test_correct_file_path_generated(self): + submission = ApplicationSubmissionFactory() + + for file_id in submission.file_field_ids: + + def check_generated_file_path(file_to_test): + file_path_generated = file_to_test.generate_filename() + file_path_required = os.path.join('submission', str(submission.id), str(file_id), file_to_test.basename) + + self.assertEqual(file_path_generated, file_path_required) + + file_response = submission.data(file_id) + if isinstance(file_response, list): + for stream_file in file_response: + check_generated_file_path(stream_file) + else: + check_generated_file_path(file_response) + def test_create_revision_on_create(self): submission = ApplicationSubmissionFactory() self.assertEqual(submission.revisions.count(), 1)