@@ -70,7 +70,8 @@ class ChangeMode(unittest.TestCase):
7070 def setUp (self ):
7171 self .tmp = tempfile .TemporaryDirectory ()
7272 self .ws , self .out , self .theme = delivered_workspace (Path (self .tmp .name ) / 'Application Support' )
73- self .env = {'H2WP_WORKSPACE' : str (self .ws ), 'H2WP_OUTPUT_DIR' : str (self .out ), 'H2WP_MODE' : 'flash' }
73+ # What the app sets on every command of a chat turn after delivery.
74+ self .env = {'H2WP_WORKSPACE' : str (self .ws ), 'H2WP_OUTPUT_DIR' : str (self .out ), 'H2WP_MODE' : 'change' }
7475
7576 def tearDown (self ):
7677 self .tmp .cleanup ()
@@ -96,18 +97,25 @@ def test_a_change_is_made_in_the_theme_and_logged_without_a_stage(self):
9697
9798 def test_the_guard_a_delivered_project_starts_no_stage (self ):
9899 before = (self .ws / 'progress.json' ).read_text ()
99- for args in (('start' , '-1' ), ('start' , '0' ), ('mode' , 'flash' ), ('mode' , 'full' )):
100- done = run ('bash' , HERE / 'progress.sh' , * args , env = self .env )
101- self .assertEqual (done .returncode , 3 , args )
100+ stale = {** self .env , 'H2WP_MODE' : 'flash' } # a shell that kept the run's mode
101+ for args , env in [(a , e ) for a in (('start' , '-1' ), ('start' , '0' ), ('mode' , 'flash' ), ('mode' , 'full' ))
102+ for e in (self .env , stale )]:
103+ done = run ('bash' , HERE / 'progress.sh' , * args , env = env )
104+ self .assertEqual (done .returncode , 3 , (args , env ['H2WP_MODE' ]))
102105 self .assertIn ('apply-change.py' , done .stderr )
103106 # The owner's rule: a change never points at starting over.
104107 self .assertNotRegex (done .stderr .lower (), r'rebuild|--new|start over' )
105108 self .assertEqual ((self .ws / 'progress.json' ).read_text (), before , 'a refusal writes nothing: still delivered' )
106- rebuild = run ('bash' , HERE / 'progress.sh' , 'mode' , 'flash' , '--new' , env = self .env )
109+ results = [(f / 'result.json' ).read_text () for f in (self .ws , self .out )]
110+ done = run (sys .executable , HERE / 'write-result.py' , self .ws , '--no-pdf' , env = self .env )
111+ self .assertEqual (done .returncode , 3 , 'a change turn never rewrites the delivered result' )
112+ self .assertEqual ([(f / 'result.json' ).read_text () for f in (self .ws , self .out )], results )
113+ # The app's "Start over from the original": the run's own mode, --new.
114+ rebuild = run ('bash' , HERE / 'progress.sh' , 'mode' , 'flash' , '--new' , env = stale )
107115 self .assertEqual (rebuild .returncode , 0 , rebuild .stderr )
108116 self .assertFalse ((self .ws / 'result.json' ).exists ())
109117 self .assertEqual (len (list (self .ws .glob ('result-*.json' ))), 1 )
110- self .assertEqual (run ('bash' , HERE / 'progress.sh' , 'start' , '-4' , env = self . env ).returncode , 0 )
118+ self .assertEqual (run ('bash' , HERE / 'progress.sh' , 'start' , '-4' , env = stale ).returncode , 0 )
111119
112120 def test_get_zip_packages_the_live_theme_as_the_next_revision (self ):
113121 package = lambda : run (sys .executable , HERE / 'package-theme.py' , self .ws , env = self .env )
0 commit comments