33from dotenv import load_dotenv
44import os
55import asyncio
6- from pathlib import Path
6+ from pathlib import Path
77import importlib .util
88
9+
910class test_main_function (unittest .TestCase ):
1011 def setUp (self ):
1112 # Replace placeholder values with .env values
@@ -21,12 +22,18 @@ def setUp(self):
2122 self .es_agent_url = os .getenv ("ES_AGENT_URL" )
2223 self .es_api_key = os .getenv ("ES_API_KEY" )
2324 content = self .test_file .read_text ()
24- modified_content = content .replace ("<YOUR-ELASTIC-AGENT-BUILDER-URL>" , self .es_agent_url )
25- modified_content = modified_content .replace ("<YOUR-ELASTIC-API-KEY>" , self .es_api_key )
25+ modified_content = content .replace (
26+ "<YOUR-ELASTIC-AGENT-BUILDER-URL>" , self .es_agent_url
27+ )
28+ modified_content = modified_content .replace (
29+ "<YOUR-ELASTIC-API-KEY>" , self .es_api_key
30+ )
2631 self .test_file .write_text (modified_content )
2732
2833 # Import the modified module
29- spec = importlib .util .spec_from_file_location ("elastic_agent_builder_a2a" , self .test_file )
34+ spec = importlib .util .spec_from_file_location (
35+ "elastic_agent_builder_a2a" , self .test_file
36+ )
3037 self .user_input_module = importlib .util .module_from_spec (spec )
3138 spec .loader .exec_module (self .user_input_module )
3239
@@ -35,13 +42,13 @@ def tearDown(self):
3542 self .test_file .write_text (self .backup_file .read_text ())
3643 self .backup_file .unlink ()
3744
38-
39- @patch ('builtins.input' , return_value = 'hello world' )
40- @patch ('builtins.print' )
45+ @patch ("builtins.input" , return_value = "hello world" )
46+ @patch ("builtins.print" )
4147 def test_main_input (self , mock_print , mock_input ):
4248 # Run test
4349 asyncio .run (self .user_input_module .main ())
4450 mock_print .assert_called_with ("Hello World! 🌎" )
45-
51+
52+
4653if __name__ == "__main__" :
47- unittest .main ()
54+ unittest .main ()
0 commit comments