@@ -279,7 +279,6 @@ def test_get_theme_name_with_feature_flag(self, checkout_path, run):
279
279
mock .ANY ,
280
280
)
281
281
282
-
283
282
@patch ('readthedocs.doc_builder.base.BaseBuilder.run' )
284
283
@patch ('readthedocs.projects.models.Project.checkout_path' )
285
284
def test_append_conf_create_yaml (self , checkout_path , run ):
@@ -420,7 +419,6 @@ def test_append_conf_existing_yaml_on_root_with_invalid_setting(self, checkout_p
420
419
with self .assertRaises (MkDocsYAMLParseError ):
421
420
self .searchbuilder .append_conf ()
422
421
423
-
424
422
@patch ('readthedocs.doc_builder.base.BaseBuilder.run' )
425
423
@patch ('readthedocs.projects.models.Project.checkout_path' )
426
424
def test_dont_override_theme (self , checkout_path , run ):
@@ -489,3 +487,54 @@ def test_write_js_data_docs_dir(self, checkout_path, run, generate_rtd_data):
489
487
docs_dir = 'docs' ,
490
488
mkdocs_config = mock .ANY ,
491
489
)
490
+
491
+ @patch ('readthedocs.doc_builder.base.BaseBuilder.run' )
492
+ @patch ('readthedocs.projects.models.Project.checkout_path' )
493
+ def test_append_conf_existing_yaml_with_extra (self , checkout_path , run ):
494
+ tmpdir = tempfile .mkdtemp ()
495
+ os .mkdir (os .path .join (tmpdir , 'docs' ))
496
+ yaml_file = os .path .join (tmpdir , 'mkdocs.yml' )
497
+ yaml .safe_dump (
498
+ {
499
+ 'site_name' : 'mkdocs' ,
500
+ 'google_analytics' : ['UA-1234-5' , 'mkdocs.org' ],
501
+ 'docs_dir' : 'docs' ,
502
+ 'extra_css' : [
503
+ 'http://readthedocs.org/static/css/badge_only.css'
504
+ ],
505
+ 'extra_javascript' : ['readthedocs-data.js' ],
506
+ },
507
+ open (yaml_file , 'w' ),
508
+ )
509
+ checkout_path .return_value = tmpdir
510
+
511
+ python_env = Virtualenv (
512
+ version = self .version ,
513
+ build_env = self .build_env ,
514
+ config = None ,
515
+ )
516
+ self .searchbuilder = MkdocsHTML (
517
+ build_env = self .build_env ,
518
+ python_env = python_env ,
519
+ )
520
+ self .searchbuilder .append_conf ()
521
+
522
+ run .assert_called_with ('cat' , 'mkdocs.yml' , cwd = mock .ANY )
523
+
524
+ config = yaml .safe_load (open (yaml_file ))
525
+
526
+ self .assertEqual (
527
+ config ['extra_css' ],
528
+ [
529
+ 'http://readthedocs.org/static/css/badge_only.css' ,
530
+ 'http://readthedocs.org/static/css/readthedocs-doc-embed.css' ,
531
+ ],
532
+ )
533
+ self .assertEqual (
534
+ config ['extra_javascript' ],
535
+ [
536
+ 'readthedocs-data.js' ,
537
+ 'http://readthedocs.org/static/core/js/readthedocs-doc-embed.js' ,
538
+ 'http://readthedocs.org/static/javascript/readthedocs-analytics.js' ,
539
+ ],
540
+ )
0 commit comments