1212
1313def test_returns_version () -> None :
1414 """It returns the correct version."""
15- assert sphinx_docsearch .__version__ == "0.2.0b3 "
15+ assert sphinx_docsearch .__version__ == "0.2.0 "
1616
1717
1818@pytest .mark .sphinx ("html" , confoverrides = {"extensions" : ["sphinx_docsearch" ]})
@@ -24,6 +24,7 @@ def test_docsearch_config(app: Sphinx) -> None:
2424 assert not app .config .docsearch_app_id
2525 assert not app .config .docsearch_api_key
2626 assert not app .config .docsearch_index_name
27+ assert not app .config .docsearch_askai
2728 assert app .config .docsearch_container == "#docsearch"
2829 assert not app .config .docsearch_initial_query
2930 assert not app .config .docsearch_placeholder
@@ -59,6 +60,7 @@ def test_raises_warnings(app: Sphinx, warning: StringIO) -> None:
5960 "docsearch_app_id" : "test_app_id" ,
6061 "docsearch_api_key" : "test_api_key" ,
6162 "docsearch_index_name" : "test_docsearch_index_name" ,
63+ "docsearch_askai" : "test_docsearch_askai" ,
6264 "docsearch_container" : "test_docsearch_container" ,
6365 "docsearch_placeholder" : "test_docsearch_placeholder" ,
6466 "docsearch_initial_query" : "test_docsearch_initial_query" ,
@@ -75,9 +77,40 @@ def test_add_docsearch_config(app: Sphinx, warning: StringIO) -> None:
7577 assert app .config .docsearch_app_id == "test_app_id"
7678 assert app .config .docsearch_api_key == "test_api_key"
7779 assert app .config .docsearch_index_name == "test_docsearch_index_name"
80+ assert app .config .docsearch_askai == "test_docsearch_askai"
7881 assert app .config .docsearch_container == "test_docsearch_container"
7982 assert app .config .docsearch_placeholder == "test_docsearch_placeholder"
8083 assert app .config .docsearch_initial_query == "test_docsearch_initial_query"
8184 assert app .config .docsearch_search_parameters == {"hitsPerPage" : 5 }
8285 assert app .config .docsearch_max_results_per_group == 10
8386 assert app .config .docsearch_missing_results_url == "test_docsearch_url"
87+
88+
89+ @pytest .mark .sphinx (
90+ "html" ,
91+ confoverrides = {
92+ "extensions" : ["sphinx_docsearch" ],
93+ "docsearch_askai" : {"assistant_id" : "wrongly_spelled_key_name" },
94+ },
95+ )
96+ def test_wrong_assistant_id_key (app : Sphinx , warning : StringIO ) -> None :
97+ """It returns a warning for the Ask AI option."""
98+ app .build ()
99+ warnings = warning .getvalue ()
100+ assert "The docsearch_askai config value must have an assistant_id key." in warnings
101+ assert app .config .docsearch_askai == {"assistant_id" : "wrongly_spelled_key_name" }
102+
103+
104+ @pytest .mark .sphinx (
105+ "html" ,
106+ confoverrides = {
107+ "extensions" : ["sphinx_docsearch" ],
108+ "docsearch_askai" : {"assistantId" : "test_docsearch_assistant_id" },
109+ },
110+ )
111+ def test_correct_assistant_id_key (app : Sphinx , warning : StringIO ) -> None :
112+ """It parses the Ask AI configuration options."""
113+ app .build ()
114+ warnings = warning .getvalue ()
115+ assert "The docsearch_askai config value must have an assistant_id key." not in warnings
116+ assert app .config .docsearch_askai == {"assistantId" : "test_docsearch_assistant_id" }
0 commit comments