@@ -42,6 +42,11 @@ def setup_backtest_results() -> None:
4242    with  results_path .open ("w+" , encoding = "utf-8" ) as  file :
4343        file .write ("{}" )
4444
45+     css_path  =  Path .cwd () /  f"{ results_id }  
46+     css_path .parent .mkdir (parents = True , exist_ok = True )
47+     with  css_path .open ("w+" , encoding = "utf-8" ) as  file :
48+         file .write ("" )
49+ 
4550    results_config_path  =  results_dir  /  "config" 
4651    with  results_config_path .open ("w+" , encoding = "utf-8" ) as  file :
4752        file .write (json .dumps ({'id' : results_id }))
@@ -206,6 +211,39 @@ def test_report_mounts_given_backtest_data_source_file() -> None:
206211    mount  =  [m  for  m  in  kwargs ["mounts" ] if  m ["Target" ] ==  "/Lean/Report/bin/Debug/backtest-data-source-file.json" ][0 ]
207212    assert  mount ["Source" ] ==  str (Path .cwd () /  "Python Project"  /  "backtests"  /  "2020-01-01_00-00-00"  /  "1459804915.json" )
208213
214+ def  test_report_mounts_given_css_override_file () ->  None :
215+     docker_manager  =  mock .Mock ()
216+     docker_manager .run_image .side_effect  =  run_image 
217+     initialize_container (docker_manager_to_use = docker_manager )
218+ 
219+     result  =  CliRunner ().invoke (lean , ["report" ,
220+                                        "--css" ,
221+                                        "1459804915.css" ])
222+ 
223+     assert  result .exit_code  ==  0 
224+ 
225+     docker_manager .run_image .assert_called_once ()
226+     args , kwargs  =  docker_manager .run_image .call_args 
227+ 
228+     mount  =  [m  for  m  in  kwargs ["mounts" ] if  m ["Target" ] ==  "/Lean/Report/bin/Debug/report_override.css" ][0 ]
229+     assert  mount ["Source" ] ==  str (Path .cwd () /  "1459804915.css" )
230+ 
231+ def  test_report_runs_even_when_css_override_file_does_not_exist () ->  None :
232+     docker_manager  =  mock .Mock ()
233+     docker_manager .run_image .side_effect  =  run_image 
234+     initialize_container (docker_manager_to_use = docker_manager )
235+ 
236+     result  =  CliRunner ().invoke (lean , ["report" ,
237+                                        "--css" ,
238+                                        "1459804916.css" ])
239+ 
240+     assert  result .exit_code  ==  0 
241+ 
242+     docker_manager .run_image .assert_called_once ()
243+     args , kwargs  =  docker_manager .run_image .call_args 
244+ 
245+     mount  =  [m  for  m  in  kwargs ["mounts" ] if  m ["Target" ] ==  "/Lean/Report/bin/Debug/report_override.css" ]
246+     assert  len (mount ) ==  0 
209247
210248def  test_report_finds_latest_backtest_data_source_file_when_not_given () ->  None :
211249    docker_manager  =  mock .Mock ()
0 commit comments