@@ -670,3 +670,119 @@ async def test_invalid_starttask(one_conf, flow, scheduler, start):
670670 with pytest .raises (InputError , match = 'a///b' ):
671671 async with start (schd ):
672672 pass
673+
674+
675+ @pytest .mark .parametrize (
676+ 'a, b, c, d, validation_fail, err' ,
677+ (
678+ ('initial' , 'start' , 'stop' , 'final' , True , False ),
679+ (
680+ 'initial' , 'start' , 'final' , 'stop' , True ,
681+ "Stop cycle point '20030101T0000Z' will have no effect as it"
682+ " is after the final cycle point '20020101T0000Z'."
683+ ),
684+ (
685+ 'initial' , 'stop' , 'start' , 'final' , False ,
686+ "Stop cycle point '20010101T0000Z' will have no effect as it"
687+ " is before the start cycle point '20020101T0000Z'."
688+ ),
689+ (
690+ 'initial' , 'stop' , 'final' , 'start' , False ,
691+ "Start cycle point '20030101T0000Z' will have no effect as it"
692+ " is after the final cycle point '20020101T0000Z'."
693+ ),
694+ (
695+ 'initial' , 'final' , 'start' , 'stop' , True ,
696+ "Stop cycle point '20030101T0000Z' will have no effect as it"
697+ " is after the final cycle point '20010101T0000Z'."
698+ ),
699+ (
700+ 'initial' , 'final' , 'stop' , 'start' , True ,
701+ "Stop cycle point '20020101T0000Z' will have no effect as it"
702+ " is after the final cycle point '20010101T0000Z'."
703+ ),
704+ (
705+ 'start' , 'initial' , 'stop' , 'final' , False ,
706+ "Start cycle point '20000101T0000Z' will have no effect as it"
707+ " is before the initial cycle point '20010101T0000Z'."
708+ ),
709+ (
710+ 'start' , 'initial' , 'final' , 'stop' , True ,
711+ "Stop cycle point '20030101T0000Z' will have no effect as it"
712+ " is after the final cycle point '20020101T0000Z'."
713+ ),
714+ (
715+ 'start' , 'stop' , 'initial' , 'final' , True ,
716+ "Stop cycle point '20010101T0000Z' will have no effect as it"
717+ " is before the initial cycle point '20020101T0000Z'."
718+ ),
719+ ('start' , 'stop' , 'final' , 'initial' , True , WorkflowConfigError ),
720+ ('start' , 'final' , 'initial' , 'stop' , True , WorkflowConfigError ),
721+ ('start' , 'final' , 'stop' , 'initial' , True , WorkflowConfigError ),
722+ (
723+ 'stop' , 'initial' , 'start' , 'final' , True ,
724+ "Stop cycle point '20000101T0000Z' will have no effect as it"
725+ " is before the initial cycle point '20010101T0000Z'."
726+ ),
727+ (
728+ 'stop' , 'initial' , 'final' , 'start' , True ,
729+ "Stop cycle point '20000101T0000Z' will have no effect as it"
730+ " is before the initial cycle point '20010101T0000Z'."
731+ ),
732+ (
733+ 'stop' , 'start' , 'initial' , 'final' , True ,
734+ "Stop cycle point '20000101T0000Z' will have no effect as it"
735+ " is before the initial cycle point '20020101T0000Z'."
736+ ),
737+ ('stop' , 'start' , 'final' , 'initial' , True , WorkflowConfigError ),
738+ ('stop' , 'final' , 'initial' , 'start' , True , WorkflowConfigError ),
739+ ('stop' , 'final' , 'start' , 'initial' , True , WorkflowConfigError ),
740+ ('final' , 'initial' , 'start' , 'stop' , True , WorkflowConfigError ),
741+ ('final' , 'initial' , 'stop' , 'start' , True , WorkflowConfigError ),
742+ ('final' , 'start' , 'initial' , 'stop' , True , WorkflowConfigError ),
743+ ('final' , 'start' , 'stop' , 'initial' , True , WorkflowConfigError ),
744+ ('final' , 'stop' , 'initial' , 'start' , True , WorkflowConfigError ),
745+ ('final' , 'stop' , 'start' , 'initial' , True , WorkflowConfigError ),
746+ )
747+ )
748+ async def test_milestone_cycle_points (
749+ a ,
750+ b ,
751+ c ,
752+ d ,
753+ validation_fail ,
754+ err ,
755+ flow ,
756+ validate ,
757+ scheduler ,
758+ start ,
759+ log_filter ,
760+ caplog ,
761+ ):
762+ """Ensure that all combinations of initial, start, stop and final cycle
763+ point return sensible warnings or errors.
764+ """
765+ order = dict (zip ((a , b , c , d ), [2000 , 2001 , 2002 , 2003 ]))
766+
767+ wid = flow ({
768+ 'scheduling' : {
769+ 'initial cycle point' : order ['initial' ],
770+ 'stop after cycle point' : order ['stop' ],
771+ 'final cycle point' : order ['final' ],
772+ 'graph' : {'P1Y' : 'foo' }
773+ },
774+ })
775+ if validation_fail :
776+ if not err :
777+ validate (wid )
778+ elif isinstance (err , str ):
779+ validate (wid )
780+ assert err in caplog .messages
781+ else :
782+ with pytest .raises (err ):
783+ validate (wid )
784+
785+ else :
786+ schd = scheduler (wid , startcp = str (order ['start' ]))
787+ async with start (schd ):
788+ assert err in caplog .messages
0 commit comments