@@ -88,6 +88,18 @@ def _test_deploy(self, expected_message=None,
88
88
89
89
self ._test_state (expected_message , expected_versions , ** kwargs )
90
90
91
+ def _mock_commit (self ):
92
+ with git_utils .Commit ('gh-pages' , 'add versions.json' ) as commit :
93
+ commit .add_file (git_utils .FileInfo (
94
+ 'versions.json' ,
95
+ '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]' ,
96
+ ))
97
+ commit .add_file (git_utils .FileInfo ('1.0/page.html' , '' ))
98
+ commit .add_file (git_utils .FileInfo ('1.0/file.txt' , '' ))
99
+ commit .add_file (git_utils .FileInfo ('1.0/dir/index.html' , '' ))
100
+ commit .add_file (git_utils .FileInfo ('latest/page.html' , '' ))
101
+ commit .add_file (git_utils .FileInfo ('latest/dir/index.html' , '' ))
102
+
91
103
def test_default (self ):
92
104
commands .deploy (self .cfg , '1.0' )
93
105
check_call_silent (['git' , 'checkout' , 'gh-pages' ])
@@ -179,18 +191,24 @@ def test_overwrite_version(self):
179
191
versions .VersionInfo ('1.0' , '1.0.1' , ['latest' , 'greatest' ])
180
192
])
181
193
182
- def test_overwrite_alias (self ):
183
- with git_utils .Commit ('gh-pages' , 'add versions.json' ) as commit :
184
- commit .add_file (git_utils .FileInfo (
185
- 'versions.json' ,
186
- '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]' ,
187
- ))
188
- commit .add_file (git_utils .FileInfo ('1.0/page.html' , '' ))
189
- commit .add_file (git_utils .FileInfo ('1.0/file.txt' , '' ))
190
- commit .add_file (git_utils .FileInfo ('1.0/dir/index.html' , '' ))
191
- commit .add_file (git_utils .FileInfo ('latest/page.html' , '' ))
192
- commit .add_file (git_utils .FileInfo ('latest/dir/index.html' , '' ))
194
+ def test_overwrite_same_alias (self ):
195
+ self ._mock_commit ()
196
+ commands .deploy (self .cfg , '1.0' , '1.0.1' , ['latest' ])
197
+ check_call_silent (['git' , 'checkout' , 'gh-pages' ])
198
+ self ._test_deploy (expected_versions = [
199
+ versions .VersionInfo ('1.0' , '1.0.1' , ['latest' ])
200
+ ])
193
201
202
+ def test_overwrite_include_same_alias (self ):
203
+ self ._mock_commit ()
204
+ commands .deploy (self .cfg , '1.0' , '1.0.1' , ['latest' , 'greatest' ])
205
+ check_call_silent (['git' , 'checkout' , 'gh-pages' ])
206
+ self ._test_deploy (expected_versions = [
207
+ versions .VersionInfo ('1.0' , '1.0.1' , ['latest' , 'greatest' ])
208
+ ])
209
+
210
+ def test_overwrite_alias_error (self ):
211
+ self ._mock_commit ()
194
212
with self .assertRaises (ValueError ):
195
213
commands .deploy (self .cfg , '2.0' , '2.0.0' , ['latest' ])
196
214
check_call_silent (['git' , 'checkout' , 'gh-pages' ])
@@ -199,17 +217,7 @@ def test_overwrite_alias(self):
199
217
])
200
218
201
219
def test_update_aliases (self ):
202
- with git_utils .Commit ('gh-pages' , 'add versions.json' ) as commit :
203
- commit .add_file (git_utils .FileInfo (
204
- 'versions.json' ,
205
- '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]' ,
206
- ))
207
- commit .add_file (git_utils .FileInfo ('1.0/page.html' , '' ))
208
- commit .add_file (git_utils .FileInfo ('1.0/file.txt' , '' ))
209
- commit .add_file (git_utils .FileInfo ('1.0/dir/index.html' , '' ))
210
- commit .add_file (git_utils .FileInfo ('latest/page.html' , '' ))
211
- commit .add_file (git_utils .FileInfo ('latest/dir/index.html' , '' ))
212
-
220
+ self ._mock_commit ()
213
221
commands .deploy (self .cfg , '2.0' , '2.0.0' , ['latest' ], True )
214
222
check_call_silent (['git' , 'checkout' , 'gh-pages' ])
215
223
self ._test_deploy ('.*' , [
@@ -341,7 +349,7 @@ def test_alias_from_alias(self):
341
349
self ._deploy ()
342
350
commands .alias (self .cfg , 'latest' , ['greatest' ])
343
351
check_call_silent (['git' , 'checkout' , 'gh-pages' ])
344
- self ._test_alias (expected_src = '1.0' )
352
+ self ._test_alias ()
345
353
346
354
def test_alias_copy (self ):
347
355
self ._deploy ()
@@ -363,6 +371,32 @@ def test_alias_custom_redirect(self):
363
371
with open ('greatest/dir/index.html' ) as f :
364
372
self .assertEqual (f .read (), '../../1.0/dir/' )
365
373
374
+ def test_alias_overwrite_same (self ):
375
+ self ._deploy ()
376
+ commands .alias (self .cfg , '1.0' , ['latest' ])
377
+ check_call_silent (['git' , 'checkout' , 'gh-pages' ])
378
+ self ._test_alias (expected_aliases = ['latest' ])
379
+
380
+ def test_alias_overwrite_include_same (self ):
381
+ self ._deploy ()
382
+ commands .alias (self .cfg , '1.0' , ['latest' , 'greatest' ])
383
+ check_call_silent (['git' , 'checkout' , 'gh-pages' ])
384
+ self ._test_alias (expected_aliases = ['latest' , 'greatest' ])
385
+
386
+ def test_alias_overwrite_error (self ):
387
+ self ._deploy ()
388
+ commands .deploy (self .cfg , '2.0' )
389
+ with self .assertRaises (ValueError ):
390
+ commands .alias (self .cfg , '2.0' , ['latest' ])
391
+ check_call_silent (['git' , 'checkout' , 'gh-pages' ])
392
+ self ._test_state (r'^Deployed \w+ to 2\.0' , [
393
+ versions .VersionInfo ('2.0' , '2.0' ),
394
+ versions .VersionInfo ('1.0' , '1.0' , ['latest' ]),
395
+ ])
396
+
397
+ def test_alias_update (self ):
398
+ pass
399
+
366
400
def test_branch (self ):
367
401
self ._deploy ('branch' )
368
402
commands .alias (self .cfg , '1.0' , ['greatest' ], branch = 'branch' )
@@ -381,7 +415,7 @@ def test_prefix(self):
381
415
check_call_silent (['git' , 'checkout' , 'gh-pages' ])
382
416
self ._test_alias (directory = 'prefix' )
383
417
384
- def test_alias_invalid (self ):
418
+ def test_alias_invalid_version (self ):
385
419
self ._deploy ()
386
420
self .assertRaises (ValueError , commands .alias , self .cfg , '2.0' ,
387
421
['alias' ])
0 commit comments