@@ -120,6 +120,9 @@ def setup_commit_history(testproject_path):
120
120
os .chdir (testproject_path )
121
121
122
122
try :
123
+ repo .git .add ("docs/page_with_tag.md" )
124
+ repo .git .commit (message = "add homepage" , author = author , date = "1500854705 -0700" )
125
+
123
126
repo .git .add ("mkdocs.yml" )
124
127
repo .git .commit (message = "add mkdocs" , author = author )
125
128
@@ -139,8 +142,12 @@ def setup_commit_history(testproject_path):
139
142
repo .git .commit (message = "second page" , author = author )
140
143
repo .git .add ("docs/index.md" )
141
144
repo .git .commit (message = "homepage" , author = author )
145
+
146
+ file_name = os .path .join (testproject_path , "docs/page_with_tag.md" )
147
+ with open (file_name , "a" ) as the_file :
148
+ the_file .write ("awa\n " )
142
149
repo .git .add ("docs/page_with_tag.md" )
143
- repo .git .commit (message = "homepage" , author = author )
150
+ repo .git .commit (message = "update homepage" , author = author )
144
151
os .chdir (cwd )
145
152
except :
146
153
os .chdir (cwd )
@@ -204,7 +211,22 @@ def validate_build(testproject_path, plugin_config: dict = {}):
204
211
)
205
212
206
213
searches = [x in contents for x in date_formats .values ()]
207
- assert any (searches ), "No correct date formats output was found"
214
+ assert any (searches ), "No correct revision date formats output was found"
215
+
216
+ if plugin_config .get ("enable_creation_date" ):
217
+ commit_timestamp = repo .get_git_commit_timestamp (
218
+ path = str (testproject_path / "docs/page_with_tag.md" ),
219
+ is_first_commit = True ,
220
+ fallback_to_build_date = plugin_config .get ("fallback_to_build_date" ),
221
+ )
222
+ assert commit_timestamp == 1500854705
223
+ date_formats = repo .get_revision_date_for_file (
224
+ commit_timestamp = commit_timestamp ,
225
+ locale = plugin_config .get ("locale" ), # type: ignore
226
+ )
227
+
228
+ searches = [x in contents for x in date_formats .values ()]
229
+ assert any (searches ), "No correct creation date formats output was found"
208
230
209
231
210
232
def validate_mkdocs_file (temp_path : str , mkdocs_yml_file : str ):
@@ -273,6 +295,11 @@ def test_build_no_options(tmp_path):
273
295
validate_mkdocs_file (tmp_path , "tests/fixtures/basic_project/mkdocs.yml" )
274
296
275
297
298
+ def test_build_creation_date (tmp_path ):
299
+ # Enable plugin with no extra options set
300
+ validate_mkdocs_file (tmp_path , "tests/fixtures/basic_project/mkdocs_creation_date.yml" )
301
+
302
+
276
303
def test_build_locale_plugin (tmp_path ):
277
304
# Enable plugin with plugin locale set to 'nl'
278
305
validate_mkdocs_file (
0 commit comments