1-
21import os
32
43import numpy as np
1110
1211from core_function import client_search_testing
1312
13+
1414@pytest .mark .skipif (os .getenv ("MP_API_KEY" ) is None , reason = "No API key found." )
1515def test_phonon_search ():
1616 client_search_testing (
@@ -24,23 +24,23 @@ def test_phonon_search():
2424 alt_name_dict = {
2525 "material_ids" : "material_id" ,
2626 },
27- custom_field_tests = {
28- "material_ids" : ["mp-149" ,"mp-13" ],
27+ custom_field_tests = {
28+ "material_ids" : ["mp-149" , "mp-13" ],
2929 "material_ids" : "mp-149" ,
3030 "phonon_method" : "dfpt" ,
3131 },
3232 sub_doc_fields = [],
3333 )
3434
35+
3536@pytest .mark .skipif (os .getenv ("MP_API_KEY" ) is None , reason = "No API key found." )
36- @pytest .mark .parametrize ("use_document_model" ,[True ,False ])
37+ @pytest .mark .parametrize ("use_document_model" , [True , False ])
3738def test_phonon_get_methods (use_document_model ):
38-
3939 rester = PhononRester (use_document_model = use_document_model )
4040
4141 # TODO: update when there is force constant data
4242 for func_name , schema in {
43- "bandstructure" : PhononBS ,
43+ "bandstructure" : PhononBS ,
4444 "dos" : PhononDOS ,
4545 # "forceconstants": list
4646 }.items ():
@@ -49,31 +49,29 @@ def test_phonon_get_methods(use_document_model):
4949 f"get_{ func_name } _from_material_id" ,
5050 )
5151 assert isinstance (
52- search_method ("mp-149" ,"dfpt" ),
53- schema if use_document_model else dict
52+ search_method ("mp-149" , "dfpt" ), schema if use_document_model else dict
5453 )
5554
56- with pytest .raises (MPRestError ,match = "No object found" ):
57- _ = search_method ("mp-0" ,"dfpt" )
55+ with pytest .raises (MPRestError , match = "No object found" ):
56+ _ = search_method ("mp-0" , "dfpt" )
57+
5858
5959@pytest .mark .skipif (os .getenv ("MP_API_KEY" ) is None , reason = "No API key found." )
60- @pytest .mark .parametrize ("use_document_model" ,[True ,False ])
60+ @pytest .mark .parametrize ("use_document_model" , [True , False ])
6161def test_phonon_thermo (use_document_model ):
62-
63- with pytest .raises (MPRestError ,match = "No phonon document found" ):
62+ with pytest .raises (MPRestError , match = "No phonon document found" ):
6463 _ = PhononRester (
6564 use_document_model = use_document_model
66- ).compute_thermo_quantities ("mp-0" ,"dfpt" )
65+ ).compute_thermo_quantities ("mp-0" , "dfpt" )
6766
6867 thermo_props = PhononRester (
6968 use_document_model = use_document_model
70- ).compute_thermo_quantities ("mp-149" ,"dfpt" )
71-
69+ ).compute_thermo_quantities ("mp-149" , "dfpt" )
70+
7271 # Default set in the method
7372 num_vals = 100
74-
73+
7574 assert all (
76- isinstance (v , np .ndarray if k == "temperature" else list )
77- and len (v ) == num_vals
75+ isinstance (v , np .ndarray if k == "temperature" else list ) and len (v ) == num_vals
7876 for k , v in thermo_props .items ()
79- )
77+ )
0 commit comments