Projet

Général

Profil

0001-matomo-pass-WS-argument-into-querysting-66833.patch

Nicolas Roche, 30 juin 2022 17:12

Télécharger (2,27 ko)

Voir les différences:

Subject: [PATCH] matomo: pass WS argument into querysting (#66833)

 hobo/matomo/utils.py       | 2 +-
 tests/test_matomo_utils.py | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
hobo/matomo/utils.py
157 157
        if not success:
158 158
            raise MatomoException(message + ' fails')
159 159
        return success
160 160

  
161 161
    def call(self, data):
162 162
        data['module'] = 'API'
163 163
        data['token_auth'] = self.token_auth
164 164
        data['language'] = 'en'
165
        resp = requests.post(self.url_ws_base, data=data)
165
        resp = requests.post(self.url_ws_base, params=data)
166 166
        if resp.status_code != 200:
167 167
            raise MatomoException('unexpected status code: %s' % resp.status_code)
168 168
        tree = self.parse_response(resp.content)
169 169
        self.raise_on_error(tree)
170 170
        return tree
171 171

  
172 172
    def get_site_id_from_site_url(self, url):
173 173
        data = {'method': 'SitesManager.getSitesIdFromSiteUrl', 'url': url}
tests/test_matomo_utils.py
516 516
    mocked_post.return_value.status_code = 200
517 517
    with override_settings(MATOMO_SERVER=CONFIG):
518 518
        matomo = MatomoWS()
519 519

  
520 520
        # success
521 521
        content = MATOMO_SUCCESS
522 522
        mocked_post.return_value.content = content
523 523
        matomo.add_user('hobo.dev.publik.love', 'xxx', '42')
524
        assert True
524
        # the mail will be quoted when passed on url
525
        assert (
526
            mocked_post.mock_calls[0][2]['params']['email'] == 'noreply+hobo.dev.publik.love@entrouvert.test'
527
        )
525 528

  
526 529
        # error (user already here)
527 530
        content = USER_ALREADY_THERE
528 531
        mocked_post.return_value.content = content
529 532
        with pytest.raises(MatomoError, match="Username 'hobo.dev.publik.love' already"):
530 533
            matomo.add_user('hobo.dev.publik.love', 'xxx', '42')
531 534

  
532 535
        # error (mail already registered)
533
-