1515
1616loader = GitAutograderTestLoader (REPOSITORY_NAME , verify )
1717
18- FEATURES = """
18+ FEATURES_FILE_CONTENT_DELETE_COMMIT = """
1919# Features
2020
2121## Creating Books
3232Allows deleting books.
3333"""
3434
35+ FEATURES_FILE_CONTENT_SEARCH_COMMIT = """
36+ # Features
37+
38+ ## Creating Books
39+
40+ Allows creating one book at a time.
41+
42+ ## Searching for Books
43+
44+ Allows searching for books by keywords.
45+ Works only for book titles.
46+ """
47+
48+ FEATURES_FILE_CONTENT_FIX_HEADINGS_COMMIT = """
49+ # Features
50+
51+ ## Creating Books
52+
53+ Allows creating one book at a time.
54+ """
55+
56+
57+ FEATURES_FILE_CONTENT_CREATE_COMMIT = """
58+ # Features
59+
60+ ## Create Book
61+
62+ Allows creating one book at a time.
63+ """
64+
65+ FEATURES_FILE_CONTENT_FEATURES_COMMIT = """
66+ # Features
67+ """
68+
3569
3670def test_base ():
3771 with loader .start () as (test , rs ):
38- rs .git .commit (message = "Add features.md" , allow_empty = True )
72+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_FEATURES_COMMIT )
73+ rs .git .add ("features.md" )
74+ rs .git .commit (message = "Add features.md" )
3975 rs .helper (GitMasteryHelper ).create_start_tag ()
40- rs .git .commit (message = "Mention feature for creating books" , allow_empty = True )
76+
77+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_CREATE_COMMIT )
78+ rs .git .add ("features.md" )
79+ rs .git .commit (message = "Mention feature for creating books" )
4180 rs .git .tag ("v1.0" )
42- rs .git .commit (message = "Fix phrasing of heading" , allow_empty = True )
43- rs .git .commit (message = "Add the search feature" , allow_empty = True )
44- rs .git .commit (message = "Add the delete feature" , allow_empty = True )
45- rs .files .create_or_update ("features.md" , FEATURES )
81+
82+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_FIX_HEADINGS_COMMIT )
83+ rs .git .add ("features.md" )
84+ rs .git .commit (message = "Fix phrasing of heading" )
85+
86+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_SEARCH_COMMIT )
87+ rs .git .add ("features.md" )
88+ rs .git .commit (message = "Add the search feature" )
89+
90+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
91+ rs .git .add ("features.md" )
92+ rs .git .commit (message = "Add the delete feature" )
4693
4794 output = test .run ()
4895 assert_output (output , GitAutograderStatus .SUCCESSFUL )
4996
5097
98+ def test_invalid_features_content ():
99+ with loader .start () as (test , rs ):
100+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_FEATURES_COMMIT )
101+ rs .git .add ("features.md" )
102+ rs .git .commit (message = "Add features.md" )
103+ rs .helper (GitMasteryHelper ).create_start_tag ()
104+
105+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_CREATE_COMMIT )
106+ rs .git .add ("features.md" )
107+ rs .git .commit (message = "Mention feature for creating books" )
108+ rs .git .tag ("v1.0" )
109+
110+ rs .git .commit (message = "Fix phrasing of heading" , allow_empty = True )
111+
112+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_SEARCH_COMMIT )
113+ rs .git .add ("features.md" )
114+ rs .git .commit (message = "Add the search feature" )
115+
116+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
117+ rs .git .add ("features.md" )
118+ rs .git .commit (message = "Add the delete feature" )
119+
120+ output = test .run ()
121+ assert_output (output , GitAutograderStatus .UNSUCCESSFUL , [FEATURES_FILE_CONTENT_INVALID .format (commit = "Fix phrasing of heading" )])
122+
123+
51124def test_non_squash_merge_used ():
52125 with loader .start () as (test , rs ):
53126 rs .git .commit (message = "Add features.md" , allow_empty = True )
@@ -62,7 +135,7 @@ def test_non_squash_merge_used():
62135 rs .git .merge ("feature-search" )
63136
64137 rs .git .commit (message = "Add the delete feature" , allow_empty = True )
65- rs .files .create_or_update ("features.md" , FEATURES )
138+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
66139
67140 output = test .run ()
68141 # This would fail because the squash merge changes the commit messages and the contents
@@ -91,7 +164,7 @@ def test_non_squash_merge_used_2():
91164 rs .git .merge ("feature-search" , no_ff = True )
92165
93166 rs .git .commit (message = "Add the delete feature" , allow_empty = True )
94- rs .files .create_or_update ("features.md" , FEATURES )
167+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
95168
96169 output = test .run ()
97170 assert_output (
@@ -110,7 +183,7 @@ def test_wrong_commit_message():
110183 rs .git .commit (message = "Fix phrasing of heading" , allow_empty = True )
111184 rs .git .commit (message = "Add the search feature!" , allow_empty = True )
112185 rs .git .commit (message = "Add the delete feature" , allow_empty = True )
113- rs .files .create_or_update ("features.md" , FEATURES )
186+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
114187
115188 output = test .run ()
116189 assert_output (
@@ -132,7 +205,7 @@ def test_missing_commit():
132205 rs .git .tag ("v1.0" )
133206 rs .git .commit (message = "Fix phrasing of heading" , allow_empty = True )
134207 rs .git .commit (message = "Add the search feature" , allow_empty = True )
135- rs .files .create_or_update ("features.md" , FEATURES )
208+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
136209
137210 output = test .run ()
138211 assert_output (
@@ -160,7 +233,7 @@ def test_branches_not_deleted():
160233 rs .git .branch ("feature-delete" )
161234 rs .git .branch ("list" )
162235
163- rs .files .create_or_update ("features.md" , FEATURES )
236+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT )
164237
165238 output = test .run ()
166239 assert_output (
@@ -183,11 +256,11 @@ def test_features_content_invalid():
183256 rs .git .commit (message = "Fix phrasing of heading" , allow_empty = True )
184257 rs .git .commit (message = "Add the search feature" , allow_empty = True )
185258 rs .git .commit (message = "Add the delete feature" , allow_empty = True )
186- rs .files .create_or_update ("features.md" , FEATURES [0 ])
259+ rs .files .create_or_update ("features.md" , FEATURES_FILE_CONTENT_DELETE_COMMIT [0 ])
187260
188261 output = test .run ()
189262 assert_output (
190263 output ,
191264 GitAutograderStatus .UNSUCCESSFUL ,
192- [FEATURES_FILE_CONTENT_INVALID ],
265+ [FEATURES_FILE_CONTENT_INVALID . format ( commit = "Add features.md" ) ],
193266 )
0 commit comments