Project

General

Profile

0001-mdph13-remove-check_status-31452.patch

Benjamin Dauvergne, 15 Mar 2019 01:39 PM

Download (2.42 KB)

View differences:

Subject: [PATCH] mdph13: remove check_status (#31452)

 passerelle/contrib/mdph13/models.py |  8 -------
 tests/test_mdph13.py                | 36 -----------------------------
 2 files changed, 44 deletions(-)
passerelle/contrib/mdph13/models.py
167 167

  
168 168
        return data
169 169

  
170
    def check_status(self):
171
        try:
172
            link = Link.objects.latest('created')
173
        except Link.DoesNotExist:
174
            return
175
        # no email passed, it's a background check
176
        link.get_file()
177

  
178 170
    @endpoint(name='link',
179 171
              methods=['post'],
180 172
              description=_('Create link with an extranet account'),
tests/test_mdph13.py
263 263
    assert headers['X-CD13-IP'] == IP
264 264

  
265 265

  
266
def test_check_status_no_link(mdph13):
267
    assert Link.objects.count() == 0
268
    try:
269
        mdph13.check_status()
270
    except Exception:
271
        pytest.fail('check_status() should not raise')
272

  
273

  
274
def test_check_status_with_link_nok(mdph13, mock_http):
275
    mock_http.add_response({'status_code': 500})
276
    Link.objects.create(
277
        resource=mdph13,
278
        name_id=NAME_ID,
279
        file_number=FILE_NUMBER,
280
        secret=SECRET,
281
        dob=DOB)
282
    assert Link.objects.count() == 1
283
    with pytest.raises(Exception):
284
        mdph13.check_status()
285

  
286

  
287
def test_check_status_with_link_ok(mdph13, mock_http):
288
    mock_http.add_response(VALID_RESPONSE)
289
    Link.objects.create(
290
        resource=mdph13,
291
        name_id=NAME_ID,
292
        file_number=FILE_NUMBER,
293
        secret=SECRET,
294
        dob=DOB)
295
    assert Link.objects.count() == 1
296
    try:
297
        mdph13.check_status()
298
    except Exception:
299
        pytest.fail('check_status() should not raise')
300

  
301

  
302 266
def test_link_bad_file_number(mdph13):
303 267
    with pytest.raises(APIError) as e:
304 268
        mdph13.link(request=None, NameID=NAME_ID, numero_dossier='x', secret=None,
305
-