Projet

Général

Profil

0001-tests-add-a-text-property-on-FakedResponse-38865.patch

Nicolas Roche, 24 janvier 2020 16:50

Télécharger (2,15 ko)

Voir les différences:

Subject: [PATCH 1/2] tests: add a text property on FakedResponse (#38865)

 tests/test_grenoble_gru.py | 2 +-
 tests/test_vivaticket.py   | 2 +-
 tests/utils.py             | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)
tests/test_grenoble_gru.py
119 119
@pytest.fixture(params=['01', '02', '10', '20', '21', '23', '4242'])
120 120
def remote_response(request):
121 121
    text = six.text_type(request.param)
122
    return utils.FakedResponse(index=request.param_index, text=text)
122
    return utils.FakedResponse(index=request.param_index, content=text)
123 123

  
124 124

  
125 125
def test_contact_mode_typologies_list_with_invalid_xml(app, setup):
tests/test_vivaticket.py
378 378
    assert response.json['data']['bookingCode'] == 'II0000013'
379 379

  
380 380
    # no more need to fake key response because the key is in cache
381
    mocked_post.side_effect = [utils.FakedResponse(text='This external booking code already exists.', ok=False)]
381
    mocked_post.side_effect = [utils.FakedResponse(content='This external booking code already exists.', ok=False)]
382 382
    response = app.post_json(url, params=payload)
383 383
    assert response.json['err'] == 1
384 384
    assert response.json['err_desc'] == 'This external booking code already exists.'
tests/utils.py
29 29
    def json(self):
30 30
        return json.loads(self.content)
31 31

  
32
    @property
33
    def text(self):
34
        return self.content
35

  
32 36

  
33 37
def mock_url(url=None, response='', status_code=200, headers=None):
34 38
    urlmatch_kwargs = {}
35
-