@@ -41,17 +41,14 @@ def mock_metadata():
41
41
Outputs
42
42
list - Command line arguements
43
43
"""
44
- metadata_index_false = Mock ()
45
- metadata_index_true = Mock ()
46
-
47
- metadata_index_false .lbuser4 = 24
48
- metadata_index_true .lbuser4 = - 99
49
-
44
+
45
+ metadata_index_false = 24
46
+ metadata_index_true = - 99
47
+
50
48
end_of_data = - 99
51
49
52
50
return metadata_index_false , metadata_index_true , end_of_data
53
51
54
- #Test the Imports may not be necessary
55
52
def test_parse_args (monkeypatch , mock_command_line ):
56
53
"""
57
54
This function tests the parse_args function with the fake commandline arguments
@@ -67,16 +64,7 @@ def test_parse_args(monkeypatch, mock_command_line):
67
64
assert args .amplitude == 0.4
68
65
assert args .seed == 23452
69
66
assert args .output == "restart_dump_copy_perturb.astart"
70
- #Test checking the seed
71
- #def test_set_seed(args):
72
- #Not sure if we need test but the conditionals in a function is nice.
73
-
74
-
75
- #Test creating output file
76
- #def test_creating_output_file():
77
-
78
67
79
- #Test the random generator
80
68
def test_create_perturbation (monkeypatch , mock_command_line , mock_perturbation ):
81
69
"""
82
70
This function tests the create_perturbation function with the fake commandline arguments
@@ -109,7 +97,7 @@ def test_is_end_of_file_keep_going(mock_metadata):
109
97
assert is_end_of_file (metadata_index_true , end_of_data ) == True
110
98
111
99
112
- #Test that the perturbation has been applied
100
+
113
101
def test_applying_perturbation (mock_perturbation ):
114
102
115
103
"""
@@ -124,26 +112,30 @@ def test_applying_perturbation(mock_perturbation):
124
112
The results of assertion tests.
125
113
"""
126
114
127
- #Create random perturbation
115
+ # Create random perturbation
128
116
nlon , nlat = mock_perturbation
129
117
perturbation = 0.5 * (2. * rs .random (nlon * nlat ).reshape ((nlat ,nlon ))- 1. )
130
118
perturbation [0 ] = 0
131
119
perturbation [- 1 ] = 0
132
- stash_code = 24
120
+ stash_code = 4
133
121
134
- #Create a fake data array to simulate the numpy array that is
135
- #To mock the method readfld that reads the field corresponding
136
- #To the itemcode
137
-
122
+ # Create a fake data array to simulate the numpy array that is
123
+ # To mock the method readfld that reads the field corresponding to the itemcode
124
+
138
125
shape = (nlat , nlon )
139
126
field_theta = Mock ()
140
127
field_not_theta = Mock ()
141
128
142
- field_theta .lbuser4 = 24
129
+ field_theta .lbuser4 = 4
143
130
field_not_theta .lbuser4 = 3
144
- #Testing if the perturb conditional works and if the resulting array is correct
131
+
132
+ # Testing if the perturb conditional works and if the resulting array is correct
133
+
145
134
#testing_a = np.round((perturbed_array - perturb) / np.ones(shape),0)
146
135
assert do_perturb (field_theta , stash_code ) == True
147
136
assert do_perturb (field_not_theta , stash_code ) == False
148
137
#assert perturbed_array.shape == (nlat, nlon)
149
138
#assert testing_a.all() == 1.
139
+
140
+ 148 ,0 - 1 Bot
141
+
0 commit comments