@@ -52,6 +52,10 @@ def before_each(self):
52
52
53
53
ensure_dirs_needed_by_create_user (self .configuration )
54
54
55
+ self .server_addr = ('localhost' , 4567 )
56
+ self .server_thread = self ._make_server (
57
+ self .configuration , self .logger , self .server_addr )
58
+
55
59
def _provide_configuration (self ):
56
60
return 'testconfig'
57
61
@@ -67,9 +71,6 @@ def issue_POST(self, request_path, **kwargs):
67
71
68
72
@unittest .skipIf (PY2 , "Python 3 only" )
69
73
def test__GET_returns_not_found_for_missing_path (self ):
70
- self .server_addr = ('localhost' , 4567 )
71
- self .server_thread = self ._make_server (
72
- self .configuration , self .logger , self .server_addr )
73
74
self .server_thread .start_wait_until_ready ()
74
75
75
76
status , _ = self .issue_GET ('/nonexistent' )
@@ -78,9 +79,6 @@ def test__GET_returns_not_found_for_missing_path(self):
78
79
79
80
@unittest .skipIf (PY2 , "Python 3 only" )
80
81
def test_GET_user__top_level_request (self ):
81
- self .server_addr = ('localhost' , 4567 )
82
- self .server_thread = self ._make_server (
83
- self .configuration , self .logger , self .server_addr )
84
82
self .server_thread .start_wait_until_ready ()
85
83
86
84
status , _ = self .issue_GET ('/user' )
@@ -96,42 +94,24 @@ def test_GET__user_userid_request_succeeds_with_status_ok(self):
96
94
example_username_home_dir ) # strip user from path
97
95
test_state_dir = os .path .dirname (test_user_home )
98
96
test_user_db_home = os .path .join (test_state_dir , "user_db_home" )
99
-
100
- self .server_addr = ('localhost' , 4567 )
101
- self .server_thread = self ._make_server (
102
- self .configuration , self .logger , self .server_addr )
103
97
self .server_thread .start_wait_until_ready ()
104
98
105
- the_url = '/user/%s' % (example_username ,)
106
- status , content = self .issue_GET (the_url )
99
+ status , content = self .issue_GET ('/user/dummy-user' )
107
100
108
101
self .assertEqual (status , 200 )
109
102
self .assertEqual (content , 'FOOBAR' )
110
103
111
104
@unittest .skipIf (PY2 , "Python 3 only" )
112
105
def test_GET_openid_user_username (self ):
113
- flask_app = None
114
-
115
- self .server_addr = ('localhost' , 4567 )
116
- self .server_thread = self ._make_server (
117
- self .configuration , self .logger , self .server_addr )
118
106
self .server_thread .start_wait_until_ready ()
119
107
120
- request_json = json .dumps ({})
121
- request_data = codecs .encode (request_json , 'utf8' )
122
-
123
108
status , content = self .issue_GET ('/user/dummy-user' )
124
109
125
110
self .assertEqual (status , 200 )
126
111
self .assertEqual (content , 'FOOBAR' )
127
112
128
113
@unittest .skipIf (PY2 , "Python 3 only" )
129
114
def test_POST_user__bad_input_data (self ):
130
- flask_app = None
131
-
132
- self .server_addr = ('localhost' , 4567 )
133
- self .server_thread = self ._make_server (
134
- self .configuration , self .logger , self .server_addr )
135
115
self .server_thread .start_wait_until_ready ()
136
116
137
117
status , content = self .issue_POST ('/user' , request_json = {
@@ -146,11 +126,6 @@ def test_POST_user__bad_input_data(self):
146
126
147
127
@unittest .skipIf (PY2 , "Python 3 only" )
148
128
def test_POST_user (self ):
149
- flask_app = None
150
-
151
- self .server_addr = ('localhost' , 4567 )
152
- self .server_thread = self ._make_server (
153
- self .configuration , self .logger , self .server_addr )
154
129
self .server_thread .start_wait_until_ready ()
155
130
156
131
status , content = self .issue_POST ('/user' , response_encoding = 'textual' , request_json = dict (
@@ -164,7 +139,8 @@ def test_POST_user(self):
164
139
))
165
140
166
141
self .assertEqual (status , 201 )
167
- self .assertEqual (content , 'hello client!' )
142
+ self .assertIsInstance (content , dict )
143
+ self .assertIn ('unique_id' , content )
168
144
169
145
def _make_configuration (self , test_logger , server_addr ):
170
146
configuration = self .configuration
@@ -195,9 +171,6 @@ def _on_instance(server):
195
171
196
172
class MigServerGrid_openid__existing_user (MigTestCase , HttpAssertMixin ):
197
173
def before_each (self ):
198
- self .server_addr = None
199
- self .server_thread = None
200
-
201
174
ensure_dirs_needed_by_create_user (self .configuration )
202
175
203
176
user_dict = {
@@ -212,6 +185,10 @@ def before_each(self):
212
185
create_user (user_dict , self .configuration ,
213
186
keyword_auto , default_renew = True )
214
187
188
+ self .server_addr = ('localhost' , 4567 )
189
+ self .server_thread = self ._make_server (
190
+ self .configuration , self .logger , self .server_addr )
191
+
215
192
def _provide_configuration (self ):
216
193
return 'testconfig'
217
194
@@ -221,11 +198,6 @@ def after_each(self):
221
198
222
199
@unittest .skipIf (PY2 , "Python 3 only" )
223
200
def test_GET_openid_user_find (self ):
224
- flask_app = None
225
-
226
- self .server_addr = ('localhost' , 4567 )
227
- self .server_thread = self ._make_server (
228
- self .configuration , self .logger , self .server_addr )
229
201
self .server_thread .start_wait_until_ready ()
230
202
231
203
status , content = self ._issue_GET (self .server_addr , '/user/find' , {
0 commit comments