@@ -739,3 +739,119 @@ async def test_task_event_bad_custom_template(
739739 with pytest .raises (WorkflowConfigError , match = exception ):
740740 async with start (schd ):
741741 pass
742+
743+
744+ @pytest .mark .parametrize (
745+ 'a, b, c, d, validation_fail, err' ,
746+ (
747+ ('initial' , 'start' , 'stop' , 'final' , True , False ),
748+ (
749+ 'initial' , 'start' , 'final' , 'stop' , True ,
750+ "stop cycle point '20030101T0000Z' will have no effect as it"
751+ " is after the final cycle point '20020101T0000Z'."
752+ ),
753+ (
754+ 'initial' , 'stop' , 'start' , 'final' , False ,
755+ "stop cycle point '20010101T0000Z' will have no effect as it"
756+ " is before the start cycle point '20020101T0000Z'."
757+ ),
758+ (
759+ 'initial' , 'stop' , 'final' , 'start' , False ,
760+ "start cycle point '20030101T0000Z' will have no effect as it"
761+ " is after the final cycle point '20020101T0000Z'."
762+ ),
763+ (
764+ 'initial' , 'final' , 'start' , 'stop' , True ,
765+ "stop cycle point '20030101T0000Z' will have no effect as it"
766+ " is after the final cycle point '20010101T0000Z'."
767+ ),
768+ (
769+ 'initial' , 'final' , 'stop' , 'start' , True ,
770+ "stop cycle point '20020101T0000Z' will have no effect as it"
771+ " is after the final cycle point '20010101T0000Z'."
772+ ),
773+ (
774+ 'start' , 'initial' , 'stop' , 'final' , False ,
775+ "start cycle point '20000101T0000Z' will have no effect as it"
776+ " is before the initial cycle point '20010101T0000Z'."
777+ ),
778+ (
779+ 'start' , 'initial' , 'final' , 'stop' , True ,
780+ "stop cycle point '20030101T0000Z' will have no effect as it"
781+ " is after the final cycle point '20020101T0000Z'."
782+ ),
783+ (
784+ 'start' , 'stop' , 'initial' , 'final' , True ,
785+ "stop cycle point '20010101T0000Z' will have no effect as it"
786+ " is before the initial cycle point '20020101T0000Z'."
787+ ),
788+ ('start' , 'stop' , 'final' , 'initial' , True , WorkflowConfigError ),
789+ ('start' , 'final' , 'initial' , 'stop' , True , WorkflowConfigError ),
790+ ('start' , 'final' , 'stop' , 'initial' , True , WorkflowConfigError ),
791+ (
792+ 'stop' , 'initial' , 'start' , 'final' , True ,
793+ "stop cycle point '20000101T0000Z' will have no effect as it"
794+ " is before the initial cycle point '20010101T0000Z'."
795+ ),
796+ (
797+ 'stop' , 'initial' , 'final' , 'start' , True ,
798+ "stop cycle point '20000101T0000Z' will have no effect as it"
799+ " is before the initial cycle point '20010101T0000Z'."
800+ ),
801+ (
802+ 'stop' , 'start' , 'initial' , 'final' , True ,
803+ "stop cycle point '20000101T0000Z' will have no effect as it"
804+ " is before the initial cycle point '20020101T0000Z'."
805+ ),
806+ ('stop' , 'start' , 'final' , 'initial' , True , WorkflowConfigError ),
807+ ('stop' , 'final' , 'initial' , 'start' , True , WorkflowConfigError ),
808+ ('stop' , 'final' , 'start' , 'initial' , True , WorkflowConfigError ),
809+ ('final' , 'initial' , 'start' , 'stop' , True , WorkflowConfigError ),
810+ ('final' , 'initial' , 'stop' , 'start' , True , WorkflowConfigError ),
811+ ('final' , 'start' , 'initial' , 'stop' , True , WorkflowConfigError ),
812+ ('final' , 'start' , 'stop' , 'initial' , True , WorkflowConfigError ),
813+ ('final' , 'stop' , 'initial' , 'start' , True , WorkflowConfigError ),
814+ ('final' , 'stop' , 'start' , 'initial' , True , WorkflowConfigError ),
815+ )
816+ )
817+ async def test_milestone_cycle_points (
818+ a ,
819+ b ,
820+ c ,
821+ d ,
822+ validation_fail ,
823+ err ,
824+ flow ,
825+ validate ,
826+ scheduler ,
827+ start ,
828+ log_filter ,
829+ caplog ,
830+ ):
831+ """Ensure that all combinations of initial, start, stop and final cycle
832+ point return sensible warnings or errors.
833+ """
834+ order = dict (zip ((a , b , c , d ), [2000 , 2001 , 2002 , 2003 ]))
835+
836+ wid = flow ({
837+ 'scheduling' : {
838+ 'initial cycle point' : order ['initial' ],
839+ 'stop after cycle point' : order ['stop' ],
840+ 'final cycle point' : order ['final' ],
841+ 'graph' : {'P1Y' : 'foo' }
842+ },
843+ })
844+ if validation_fail :
845+ if not err :
846+ validate (wid )
847+ elif isinstance (err , str ):
848+ validate (wid )
849+ assert err in caplog .messages
850+ else :
851+ with pytest .raises (err ):
852+ validate (wid )
853+
854+ else :
855+ schd = scheduler (wid , startcp = str (order ['start' ]))
856+ async with start (schd ):
857+ assert err in caplog .messages
0 commit comments