Projet

Général

Profil

0001-sms-display-SMS-connector-fields-45817.patch

Nicolas Roche, 10 septembre 2020 17:43

Télécharger (3,22 ko)

Voir les différences:

Subject: [PATCH] sms: display SMS connector fields (#45817)

 .../manage/messages_service_view.html         |  4 ---
 tests/test_sms.py                             | 27 +++++++++++++++++++
 2 files changed, 27 insertions(+), 4 deletions(-)
passerelle/sms/templates/passerelle/manage/messages_service_view.html
1 1
{% extends "passerelle/manage/service_view.html" %}
2 2
{% load i18n passerelle %}
3 3

  
4
{% block description %}
5
{% if object.description %}{{object.description|linebreaks}}{% endif %}
6
{% endblock %}
7

  
8 4
{% block endpoints %}
9 5
<ul>
10 6
 <li>{% trans 'Sending a message:' %} <a href="send" >{{ site_base_uri }}{{ object.get_absolute_url }}send</a> (POST)</li>
11 7
</ul>
12 8
{% endblock %}
tests/test_sms.py
97 97

  
98 98
def test_manage_views(admin_user, app, connector):
99 99
    url = '/%s/%s/' % (connector.get_connector_slug(), connector.slug)
100 100
    resp = app.get(url)
101 101
    assert 'Endpoints' in resp.text
102 102
    assert not 'accessright/add' in resp.text
103 103
    app = login(app)
104 104
    resp = app.get(url)
105
    description_fields = [
106
        x.text.split(':')[0]
107
        for x in resp.html.find('div', {'id': 'description'}).find_all('p')]
108
    assert 'Default country code' in description_fields
109
    assert 'Default trunk prefix' in description_fields
110
    assert 'Maximum message length' in description_fields
111
    assert 'Account' not in description_fields
112
    assert 'Username' not in description_fields
105 113
    assert 'Endpoints' in resp.text
106 114
    assert 'accessright/add' in resp.text
107 115

  
108 116

  
117
@pytest.mark.parametrize('connector', [OVHSMSGateway], indirect=True)
118
def test_manage_views_ovh(app, connector):
119
    connector.default_country_code = '44'
120
    connector.account = 'secret'
121
    connector.application_key = 'secret'
122
    connector.application_secret = 'secret'
123
    connector.consumer_key = 'secret'
124
    connector.password = 'secret'
125
    connector.username = 'secret'
126
    connector.save()
127
    url = '/%s/%s/' % (connector.get_connector_slug(), connector.slug)
128
    resp = app.get(url)
129
    description_fields = [
130
        x.text for x in resp.html.find('div', {'id': 'description'}).find_all('p')]
131
    assert any(x for x in description_fields if 'Default country code' in x)
132
    assert any(x for x in description_fields if '44' in x)
133
    assert not any(x for x in description_fields if 'secret' in x)
134

  
135

  
109 136
@pytest.mark.parametrize('connector', [OVHSMSGateway], indirect=True)
110 137
def test_sms_max_message_length(app, connector):
111 138
    path = '/%s/%s/send/' % (connector.get_connector_slug(), connector.slug)
112 139

  
113 140
    message_above_limit = 'a' * (connector.max_message_length + 1)
114 141
    payload = {
115 142
        'message': message_above_limit,
116 143
        'from': '+33699999999',
117
-