32
32
from freeseer .frontend .controller import server
33
33
34
34
35
- def unimplemented (response ):
36
- response_data = json .loads (response .data )
37
- if response_data ['error_code' ] != 501 :
38
- return False
39
- if response .status_code != 501 :
40
- return False
41
- return True
42
-
43
-
44
35
class TestConfigurationApp :
45
-
46
36
@pytest .fixture (scope = 'module' )
47
37
def test_client (self ):
48
38
server .app .config ['TESTING' ] = True
@@ -91,7 +81,7 @@ def test_delete_profile(self, test_client):
91
81
def test_modify_profile (self , test_client , configuration ):
92
82
response = test_client .patch ('/profiles/testing' ,
93
83
data = {
94
- 'default_language' : 'tr_en_FR.qm'
84
+ 'default_language' : 'tr_en_FR.qm' ,
95
85
})
96
86
97
87
assert response .status_code == 200
@@ -107,8 +97,44 @@ def test_modify_profile_arg_needs_encoding(self, test_client):
107
97
data = {
108
98
'auto_hide' : True
109
99
})
110
- # Note: Currently returns 'Invalid Args' because config's
111
- # set_value method does not encode the value of the option.
112
- # In this case, the request object has encoded the boolean
113
- # True as the string 'true', so BooleanOption rejects it.
114
- assert response .status_code == 400
100
+ assert response .status_code == 200
101
+
102
+ def test_modify_profile_invalid_option (self , test_client ):
103
+ response = test_client .patch ('/profiles/testing' ,
104
+ data = {
105
+ 'not_a_real_option' : True
106
+ })
107
+ response_data = json .loads (response .data )
108
+ assert response_data == {
109
+ 'error_message' : 'Invalid Option: not_a_real_option' ,
110
+ 'error_code' : 400
111
+ }
112
+
113
+ def test_view_general_configuration (self , test_client , configuration ):
114
+ response = test_client .get ('/profiles/testing/general' )
115
+ response_data = json .loads (response .data )
116
+
117
+ general = configuration .profile .get_config ('freeseer.conf' ,
118
+ settings .FreeseerConfig ,
119
+ ['Global' ],
120
+ read_only = True )
121
+ assert response_data == {
122
+ 'default_language' : general .default_language ,
123
+ 'auto_hide' : general .auto_hide ,
124
+ }
125
+
126
+ assert response .status_code == 200
127
+
128
+ def test_modify_general_configuration (self , test_client , configuration ):
129
+ response = test_client .patch ('/profiles/testing' ,
130
+ data = {
131
+ 'default_language' : 'tr_en_FR.qm' ,
132
+ })
133
+
134
+ assert response .status_code == 200
135
+
136
+ configuration .config = configuration .profile .get_config ('freeseer.conf' ,
137
+ settings .FreeseerConfig ,
138
+ ['Global' ],
139
+ read_only = True )
140
+ assert configuration .config .default_language == 'tr_en_FR.qm'
0 commit comments