1
1
#!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
2
import unittest
4
3
import subprocess
5
4
6
5
from book_tester import ChapterTest , DO_SERVER_COMMANDS
7
6
8
7
9
8
class Chapter9Test (ChapterTest ):
10
- chapter_name = ' chapter_09_docker'
11
- previous_chapter = ' chapter_08_prettification'
9
+ chapter_name = " chapter_09_docker"
10
+ previous_chapter = " chapter_08_prettification"
12
11
13
12
def test_listings_and_commands_and_output (self ):
14
13
self .parse_listings ()
15
14
16
15
# sanity checks
17
- self .assertEqual (self .listings [0 ].type , ' code listing with git ref' )
18
- self .assertEqual (self .listings [1 ].type , ' test' )
16
+ self .assertEqual (self .listings [0 ].type , " code listing with git ref" )
17
+ self .assertEqual (self .listings [1 ].type , " test" )
19
18
20
19
self .start_with_checkout ()
21
20
22
- # skips
23
- self .skip_with_check (13 , 'replace the URL in the next line with' )
24
- self .skip_with_check (24 , 'do some git config first' )
25
- self .skip_with_check (33 , 'Performing system checks' )
26
- self .skip_with_check (44 , 'Starting development server' )
27
-
28
- if not DO_SERVER_COMMANDS :
29
- self .skip_with_check (38 , 'curl staging.ottg.co.uk' )
30
- self .skip_with_check (39 , 'Failed to connect to staging.ottg.co.uk' )
31
- self .skip_with_check (47 , 'curl staging.ottg.co.uk:8000' )
32
- self .skip_with_check (48 , '<!DOCTYPE html>' )
33
-
34
- vm_restore = None # 'MANUAL_1'
21
+ vm_restore = None # 'MANUAL_1'
35
22
36
23
# hack fast-forward
37
24
skip = False
@@ -41,18 +28,18 @@ def test_listings_and_commands_and_output(self):
41
28
# self.sourcetree.get_commit_spec('ch08l001')
42
29
# ))
43
30
self .pos = 43
44
- self .current_server_cd = ' ~/sites/$SITENAME'
45
- self .sourcetree .run_command ('git checkout {0}' . format (
46
- self .sourcetree .get_commit_spec (' ch08l004' )
47
- ))
48
- vm_restore = ' MANUAL_2'
31
+ self .current_server_cd = " ~/sites/$SITENAME"
32
+ self .sourcetree .run_command (
33
+ "git checkout {0}" . format ( self .sourcetree .get_commit_spec (" ch08l004" ) )
34
+ )
35
+ vm_restore = " MANUAL_2"
49
36
50
37
if DO_SERVER_COMMANDS :
51
38
if vm_restore :
52
- subprocess .check_call ([' vagrant' , ' snapshot' , ' restore' , vm_restore ])
39
+ subprocess .check_call ([" vagrant" , " snapshot" , " restore" , vm_restore ])
53
40
else :
54
- subprocess .check_call ([' vagrant' , ' destroy' , '-f' ])
55
- subprocess .check_call ([' vagrant' , 'up' ])
41
+ subprocess .check_call ([" vagrant" , " destroy" , "-f" ])
42
+ subprocess .check_call ([" vagrant" , "up" ])
56
43
57
44
while self .pos < len (self .listings ):
58
45
listing = self .listings [self .pos ]
@@ -62,10 +49,9 @@ def test_listings_and_commands_and_output(self):
62
49
self .assert_all_listings_checked (self .listings )
63
50
self .check_final_diff ()
64
51
if DO_SERVER_COMMANDS :
65
- subprocess .run (['vagrant' , 'snapshot' , 'delete' , 'MANUAL_END' ])
66
- subprocess .run (['vagrant' , 'snapshot' , 'save' , 'MANUAL_END' ], check = True )
67
-
52
+ subprocess .run (["vagrant" , "snapshot" , "delete" , "MANUAL_END" ])
53
+ subprocess .run (["vagrant" , "snapshot" , "save" , "MANUAL_END" ], check = True )
68
54
69
55
70
- if __name__ == ' __main__' :
56
+ if __name__ == " __main__" :
71
57
unittest .main ()
0 commit comments