mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
View to show all inbound sms numbers for the platform admin user.
This commit is contained in:
@@ -12,7 +12,7 @@ class InboundNumberClient(NotifyAdminAPIClient):
|
|||||||
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_all_inbound_sms_number_service(self):
|
def get_all_inbound_sms_number_service(self):
|
||||||
return self.get('/inbound_number')
|
return self.get('/inbound-number')
|
||||||
|
|
||||||
def get_inbound_sms_number_for_service(self, service_id):
|
def get_inbound_sms_number_for_service(self, service_id):
|
||||||
return self.get('/inbound-number/service/{}'.format(service_id))
|
return self.get('/inbound-number/service/{}'.format(service_id))
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{% extends "withnav_template.html" %}
|
{% extends "views/platform-admin/_base_template.html" %}
|
||||||
{% from "components/table.html" import list_table, row, field, hidden_field_heading %}
|
|
||||||
{% from "components/page-footer.html" import page_footer %}
|
|
||||||
|
|
||||||
{% block service_page_title %}
|
{% block service_page_title %}
|
||||||
Inbound Numbers
|
Inbound Numbers
|
||||||
@@ -8,7 +6,7 @@ Inbound Numbers
|
|||||||
|
|
||||||
{% set table_headings = {
|
{% set table_headings = {
|
||||||
'field_headings': [
|
'field_headings': [
|
||||||
'', 'Number', 'Status', 'Service', 'Created on'
|
'Number', 'Status', 'Service', 'Created on'
|
||||||
],
|
],
|
||||||
'field_headings_visible': True,
|
'field_headings_visible': True,
|
||||||
'caption_visible': True
|
'caption_visible': True
|
||||||
@@ -20,7 +18,7 @@ Inbound Numbers
|
|||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
{% block maincolumn_content %}
|
{% block platform_admin_content %}
|
||||||
|
|
||||||
<div class="grid-row bottom-gutter">
|
<div class="grid-row bottom-gutter">
|
||||||
<div class="column-two-thirds">
|
<div class="column-two-thirds">
|
||||||
@@ -31,6 +29,7 @@ Inbound Numbers
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<table class="inbound">
|
<table class="inbound">
|
||||||
<col style="width:8%">
|
<col style="width:8%">
|
||||||
<col style="width:20%">
|
<col style="width:20%">
|
||||||
@@ -41,14 +40,12 @@ Inbound Numbers
|
|||||||
<th>{{table_headings.field_headings[0]}}</th>
|
<th>{{table_headings.field_headings[0]}}</th>
|
||||||
<th>{{table_headings.field_headings[1]}}</th>
|
<th>{{table_headings.field_headings[1]}}</th>
|
||||||
<th>{{table_headings.field_headings[2]}}</th>
|
<th>{{table_headings.field_headings[2]}}</th>
|
||||||
<th>{{table_headings.field_headings[3]}}</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thread>
|
</thread>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
{% for value in inbound_num_list.data: %}
|
{% for value in inbound_num_list.data: %}
|
||||||
<tr>
|
<tr>
|
||||||
<th style="font-weight:normal;">{{loop.index}}</th>
|
|
||||||
<th style="font-weight:normal;">{{value.number}}</th>
|
<th style="font-weight:normal;">{{value.number}}</th>
|
||||||
<th style="font-weight:normal;">
|
<th style="font-weight:normal;">
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
('Trial mode services', url_for('main.trial_services')),
|
('Trial mode services', url_for('main.trial_services')),
|
||||||
('Providers', url_for('main.view_providers')),
|
('Providers', url_for('main.view_providers')),
|
||||||
('Organisations', url_for('main.organisations')),
|
('Organisations', url_for('main.organisations')),
|
||||||
('Letter jobs', url_for('main.letter_jobs'))
|
('Letter jobs', url_for('main.letter_jobs')),
|
||||||
|
('Inbound SMS numbers', url_for('main.inbound_sms_admin'))
|
||||||
] %}
|
] %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ url }}">
|
<a href="{{ url }}">
|
||||||
|
|||||||
@@ -158,3 +158,16 @@ def test_set_text_message_sender_validation(
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert page.select(".error-message")[0].text.strip() == expected_error
|
assert page.select(".error-message")[0].text.strip() == expected_error
|
||||||
assert not mock_update_service.called
|
assert not mock_update_service.called
|
||||||
|
|
||||||
|
|
||||||
|
def test_if_sms_sender_set_then_form_populated(
|
||||||
|
logged_in_client,
|
||||||
|
service_one,
|
||||||
|
mock_get_inbound_number_for_service
|
||||||
|
):
|
||||||
|
service_one['sms_sender'] = 'elevenchars'
|
||||||
|
response = logged_in_client.get(url_for('main.service_set_sms_sender', service_id=service_one['id']))
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
assert page.find(id='sms_sender')['value'] == 'elevenchars'
|
||||||
34
tests/app/main/views/test_inbound_sms_admin.py
Normal file
34
tests/app/main/views/test_inbound_sms_admin.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
sample_inbound_sms = {'data': [{"id": "activated",
|
||||||
|
"number": "0784121212",
|
||||||
|
"provider": "provider_one",
|
||||||
|
"service": {"id": "123234", "name": "Service One"},
|
||||||
|
"active": True,
|
||||||
|
"created_at": "2017-08-15T13:30:30.12312",
|
||||||
|
"updated_at": "2017-08-15T13:30:30.12312"},
|
||||||
|
{"id": "available",
|
||||||
|
"number": "0784131313",
|
||||||
|
"provider": "provider_one",
|
||||||
|
"service": None,
|
||||||
|
"active": True,
|
||||||
|
"created_at": "2017-08-15T13:30:30.12312",
|
||||||
|
"updated_at": None},
|
||||||
|
{"id": "deactivated",
|
||||||
|
"number": "0784131313",
|
||||||
|
"provider": "provider_one",
|
||||||
|
"service": None,
|
||||||
|
"active": True,
|
||||||
|
"created_at": "2017-08-15T13:30:30.12312",
|
||||||
|
"updated_at": None}
|
||||||
|
]}
|
||||||
|
|
||||||
|
|
||||||
|
def test_inbound_sms_admin(logged_in_platform_admin_client, mocker):
|
||||||
|
mocker.patch("app.inbound_number_client.get_all_inbound_sms_number_service", return_value=sample_inbound_sms)
|
||||||
|
response = logged_in_platform_admin_client.get(url_for("main.inbound_sms_admin"))
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
assert page.h1.string.strip() == "Inbound SMS"
|
||||||
@@ -752,19 +752,6 @@ def test_set_inbound_api_validation(
|
|||||||
assert not mock_update_service.called
|
assert not mock_update_service.called
|
||||||
|
|
||||||
|
|
||||||
def test_if_sms_sender_set_then_form_populated(
|
|
||||||
logged_in_client,
|
|
||||||
service_one,
|
|
||||||
mock_get_inbound_number_for_service
|
|
||||||
):
|
|
||||||
service_one['sms_sender'] = 'elevenchars'
|
|
||||||
response = logged_in_client.get(url_for('main.service_set_sms_sender', service_id=service_one['id']))
|
|
||||||
|
|
||||||
assert response.status_code == 200
|
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
|
||||||
assert page.find(id='sms_sender')['value'] == 'elevenchars'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('method', ['get', 'post'])
|
@pytest.mark.parametrize('method', ['get', 'post'])
|
||||||
def test_cant_set_letter_contact_block_if_service_cant_send_letters(
|
def test_cant_set_letter_contact_block_if_service_cant_send_letters(
|
||||||
logged_in_client,
|
logged_in_client,
|
||||||
|
|||||||
Reference in New Issue
Block a user