def test_process_update_revisions(self): rev = self.document.metadata.get_revision(2) self.assertEqual(rev.status, 'SPD') process_transmittal(self.transmittal.pk) rev = self.document.metadata.get_revision(2) self.assertEqual(rev.status, 'IFA')
def test_successfull_process_moves_files_to_accepted_dir(self): tobechecked_file = join(self.transmittal.full_tobechecked_name, 'toto.csv') accepted_file = join(self.transmittal.full_accepted_name, 'toto.csv') touch(tobechecked_file) self.assertTrue(os.path.exists(tobechecked_file)) self.assertFalse(os.path.exists(accepted_file)) process_transmittal(self.transmittal.pk) self.assertFalse(os.path.exists(tobechecked_file)) self.assertTrue(os.path.exists(accepted_file))
def test_process_create_revisions(self): rev = self.document.metadata.get_revision(3) self.assertIsNone(rev) process_transmittal(self.transmittal.pk) rev = self.document.metadata.get_revision(3) self.assertIsNotNone(rev) self.assertEqual(rev.status, 'IFA') rev = self.document.metadata.get_revision(4) self.assertIsNotNone(rev) self.assertEqual(rev.status, 'FIN')
def test_process_updates_files(self): rev = self.document.metadata.get_revision(1) self.assertFalse(rev.pdf_file) process_transmittal(self.transmittal.pk) rev = self.document.metadata.get_revision(1) self.assertTrue(rev.pdf_file) rev = self.document.metadata.get_revision(3) self.assertTrue(rev.pdf_file) self.assertFalse(rev.native_file) rev = self.document.metadata.get_revision(4) self.assertTrue(rev.pdf_file) self.assertTrue(rev.native_file)
def handle(self, *args, **options): from transmittals.models import Transmittal from transmittals.tasks import process_transmittal if len(args) != 1: error = 'Usage: python manage.py process_transmittal {}'.format(self.args) raise CommandError(error) transmittal = get_object_or_None(Transmittal, document__document_key=args[0]) if transmittal is None: error = 'Unknown transmittal' raise CommandError(error) if transmittal.status != 'tobechecked': error = 'Wrong transmittal status: {}'.format(transmittal.status) raise CommandError(error) transmittal.status = 'processing' transmittal.save() process_transmittal(transmittal.pk)
def handle(self, *args, **options): from transmittals.models import Transmittal from transmittals.tasks import process_transmittal if len(args) != 1: error = 'Usage: python manage.py process_transmittal {}'.format( self.args) raise CommandError(error) transmittal = get_object_or_None(Transmittal, document__document_key=args[0]) if transmittal is None: error = 'Unknown transmittal' raise CommandError(error) if transmittal.status != 'tobechecked': error = 'Wrong transmittal status: {}'.format(transmittal.status) raise CommandError(error) transmittal.status = 'processing' transmittal.save() process_transmittal(transmittal.pk)