55
66
77def test_check_parameters_for_bash ():
8+
9+ # 1. ts_grid is set explictily
810 c = {"ts_grid" : "grid" }
911 check_parameters_for_bash (c )
1012
13+ # 2. ts_grid can't be set because an empty string is provided
1114 c = {"ts_grid" : "" }
1215 with pytest .raises (ParameterNotProvidedError ):
1316 check_parameters_for_bash (c )
1417
18+ # 3. ts_grid is set via ts_atm_grid
1519 c = {"component" : "atm" , "ts_atm_grid" : "atm_grid" }
1620 check_parameters_for_bash (c )
21+ # 4. ts_grid is set via ts_land_grid
1722 c = {"component" : "lnd" , "ts_land_grid" : "land_grid" }
1823 check_parameters_for_bash (c )
1924
25+ # 5. ts_grid can't be set via ts_land_grid since component is atm
2026 c = {"component" : "atm" , "ts_land_grid" : "land_grid" }
2127 with pytest .raises (ParameterNotProvidedError ):
2228 check_parameters_for_bash (c )
29+ # 6. ts_grid can't be set via ts_atm_grid since component is lnd
2330 c = {"component" : "lnd" , "ts_atm_grid" : "atm_grid" }
2431 with pytest .raises (ParameterNotProvidedError ):
2532 check_parameters_for_bash (c )
2633
34+ # 7. ts_grid can't be set via ts_atm_grid since component isn't specified
2735 c = {"ts_atm_grid" : "atm_grid" }
2836 with pytest .raises (ParameterNotProvidedError ):
2937 check_parameters_for_bash (c )
38+ # 8. ts_grid can't be set via ts_land_grid since component isn't specified
3039 c = {"ts_land_grid" : "land_grid" }
3140 with pytest .raises (ParameterNotProvidedError ):
3241 check_parameters_for_bash (c )
3342
43+ # 9. ts_grid can't be set because ts_atm_grid is set to the empty string
44+ c = {"component" : "atm" , "ts_atm_grid" : "" }
45+ with pytest .raises (ParameterNotProvidedError ):
46+ check_parameters_for_bash (c )
47+ # 10. ts_grid can't be set because ts_land_grid is set to the empty string
48+ c = {"component" : "lnd" , "ts_land_grid" : "" }
49+ with pytest .raises (ParameterNotProvidedError ):
50+ check_parameters_for_bash (c )
51+
3452
3553def test_check_and_define_parameters ():
3654 sub = "name_of_this_subsection"
3755
38- # Guess the subsection
56+ # Guess the subsection ####################################################
57+ # 1. ts_subsection is set explictily
3958 c = {"ts_subsection" : "subsection" , "guess_section_parameters" : True }
4059 check_and_define_parameters (c , sub )
4160 assert c ["ts_subsection" ] == "subsection"
4261
62+ # 2. ts_subsection is set via sub because it is initially set to the empty string
4363 c = {"ts_subsection" : "" , "guess_section_parameters" : True }
4464 check_and_define_parameters (c , sub )
4565 assert c ["ts_subsection" ] == "name_of_this_subsection"
4666
67+ # 3. ts_subsection is set via ts_atm_subsection
4768 c = {
4869 "component" : "atm" ,
4970 "ts_atm_subsection" : "atm_subsection" ,
5071 "guess_section_parameters" : True ,
5172 }
5273 check_and_define_parameters (c , sub )
5374 assert c ["ts_subsection" ] == "atm_subsection"
75+ # 4. ts_subsection is set via ts_land_subsection
5476 c = {
5577 "component" : "lnd" ,
5678 "ts_land_subsection" : "land_subsection" ,
@@ -59,13 +81,15 @@ def test_check_and_define_parameters():
5981 check_and_define_parameters (c , sub )
6082 assert c ["ts_subsection" ] == "land_subsection"
6183
84+ # 5. ts_subsection can't be set via ts_land_subsection since component is atm
6285 c = {
6386 "component" : "atm" ,
6487 "ts_land_subsection" : "land_subsection" ,
6588 "guess_section_parameters" : True ,
6689 }
6790 check_and_define_parameters (c , sub )
6891 assert c ["ts_subsection" ] == "name_of_this_subsection"
92+ # 6. ts_subsection can't be set via ts_atm_subsection since component is lnd
6993 c = {
7094 "component" : "lnd" ,
7195 "ts_atm_subsection" : "atm_subsection" ,
@@ -74,41 +98,52 @@ def test_check_and_define_parameters():
7498 check_and_define_parameters (c , sub )
7599 assert c ["ts_subsection" ] == "name_of_this_subsection"
76100
101+ # 7. ts_subsection can't be set via ts_atm_subsection since component isn't specified
77102 c = {"ts_atm_subsection" : "atm_subsection" , "guess_section_parameters" : True }
78103 check_and_define_parameters (c , sub )
79104 assert c ["ts_subsection" ] == "name_of_this_subsection"
105+ # 8. ts_subsection can't be set via ts_atm_subsection since component isn't specified
80106 c = {"ts_land_subsection" : "land_subsection" , "guess_section_parameters" : True }
81107 check_and_define_parameters (c , sub )
82108 assert c ["ts_subsection" ] == "name_of_this_subsection"
83109
110+ # 9. ts_subsection is set via sub because it is initially not provided
84111 c = {"guess_section_parameters" : True }
85112 check_and_define_parameters (c , sub )
86113 assert c ["ts_subsection" ] == "name_of_this_subsection"
87114
115+ # 10. ts_subsection is set via sub because it is initially not provided and component isn't specified (required to use ts_atm_subsection)
88116 c = {"ts_atm_subsection" : "" , "guess_section_parameters" : True }
89117 check_and_define_parameters (c , sub )
90118 assert c ["ts_subsection" ] == "name_of_this_subsection"
91119
120+ # 11. ts_subsection is set via sub because it is initially not provided and component isn't specified (required to use ts_land_subsection)
92121 c = {"ts_land_subsection" : "" , "guess_section_parameters" : True }
93122 check_and_define_parameters (c , sub )
94123 assert c ["ts_subsection" ] == "name_of_this_subsection"
95124
96- # Don't guess the subsection
125+ # Don't guess the subsection ##############################################
126+ # Repeat above cases, but with guess_section_parameters set to False
127+
128+ # 1
97129 c = {"ts_subsection" : "subsection" , "guess_section_parameters" : False }
98130 check_and_define_parameters (c , sub )
99131 assert c ["ts_subsection" ] == "subsection"
100132
133+ # 2
101134 c = {"ts_subsection" : "" , "guess_section_parameters" : False }
102135 with pytest .raises (ParameterNotProvidedError ):
103136 check_and_define_parameters (c , sub )
104137
138+ # 3
105139 c = {
106140 "component" : "atm" ,
107141 "ts_atm_subsection" : "atm_subsection" ,
108142 "guess_section_parameters" : False ,
109143 }
110144 with pytest .raises (ParameterNotProvidedError ):
111145 check_and_define_parameters (c , sub )
146+ # 4
112147 c = {
113148 "component" : "lnd" ,
114149 "ts_land_subsection" : "land_subsection" ,
@@ -117,13 +152,15 @@ def test_check_and_define_parameters():
117152 with pytest .raises (ParameterNotProvidedError ):
118153 check_and_define_parameters (c , sub )
119154
155+ # 5
120156 c = {
121157 "component" : "atm" ,
122158 "ts_land_subsection" : "land_subsection" ,
123159 "guess_section_parameters" : False ,
124160 }
125161 with pytest .raises (ParameterNotProvidedError ):
126162 check_and_define_parameters (c , sub )
163+ # 6
127164 c = {
128165 "component" : "lnd" ,
129166 "ts_atm_subsection" : "atm_subsection" ,
@@ -132,21 +169,26 @@ def test_check_and_define_parameters():
132169 with pytest .raises (ParameterNotProvidedError ):
133170 check_and_define_parameters (c , sub )
134171
172+ # 7
135173 c = {"ts_atm_subsection" : "atm_subsection" , "guess_section_parameters" : False }
136174 with pytest .raises (ParameterNotProvidedError ):
137175 check_and_define_parameters (c , sub )
176+ # 8
138177 c = {"ts_land_subsection" : "land_subsection" , "guess_section_parameters" : False }
139178 with pytest .raises (ParameterNotProvidedError ):
140179 check_and_define_parameters (c , sub )
141180
181+ # 9
142182 c = {"guess_section_parameters" : False }
143183 with pytest .raises (ParameterNotProvidedError ):
144184 check_and_define_parameters (c , sub )
145185
186+ # 10
146187 c = {"ts_atm_subsection" : "" , "guess_section_parameters" : False }
147188 with pytest .raises (ParameterNotProvidedError ):
148189 check_and_define_parameters (c , sub )
149190
191+ # 11
150192 c = {"ts_land_subsection" : "" , "guess_section_parameters" : False }
151193 with pytest .raises (ParameterNotProvidedError ):
152194 check_and_define_parameters (c , sub )
0 commit comments