@@ -421,3 +421,54 @@ def test_invalid_traj_input(tmp_path):
421421 )
422422 assert result .exit_code == 1
423423 assert isinstance (result .exception , ValueError )
424+
425+
426+ def test_displacement_kwargs (tmp_path ):
427+ """Test displacment_kwargs can be set."""
428+ file_prefix_1 = tmp_path / "NaCl_1"
429+ file_prefix_2 = tmp_path / "NaCl_2"
430+ displacement_file_1 = tmp_path / "NaCl_1-phonopy.yml"
431+ displacement_file_2 = tmp_path / "NaCl_2-phonopy.yml"
432+
433+ result = runner .invoke (
434+ app ,
435+ [
436+ "phonons" ,
437+ "--struct" ,
438+ DATA_PATH / "NaCl.cif" ,
439+ "--no-hdf5" ,
440+ "--displacement-kwargs" ,
441+ "{'is_plusminus': True}" ,
442+ "--file-prefix" ,
443+ file_prefix_1 ,
444+ ],
445+ )
446+ assert result .exit_code == 0
447+
448+ result = runner .invoke (
449+ app ,
450+ [
451+ "phonons" ,
452+ "--struct" ,
453+ DATA_PATH / "NaCl.cif" ,
454+ "--no-hdf5" ,
455+ "--displacement-kwargs" ,
456+ "{'is_plusminus': False}" ,
457+ "--file-prefix" ,
458+ file_prefix_2 ,
459+ ],
460+ )
461+ assert result .exit_code == 0
462+
463+ # Check parameters
464+ with open (displacement_file_1 , encoding = "utf8" ) as file :
465+ params = yaml .safe_load (file )
466+ n_displacments_1 = len (params ["displacements" ])
467+
468+ assert n_displacments_1 == 4
469+
470+ with open (displacement_file_2 , encoding = "utf8" ) as file :
471+ params = yaml .safe_load (file )
472+ n_displacments_2 = len (params ["displacements" ])
473+
474+ assert n_displacments_2 == 2
0 commit comments