View to show all inbound sms numbers for the platform admin user.

This commit is contained in:
Rebecca Law
2017-08-15 17:04:57 +01:00
parent 27a9180d2a
commit 8aab08d4d2
6 changed files with 54 additions and 22 deletions

View File

@@ -12,7 +12,7 @@ class InboundNumberClient(NotifyAdminAPIClient):
self.api_key = app.config['ADMIN_CLIENT_SECRET']
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):
return self.get('/inbound-number/service/{}'.format(service_id))

View File

@@ -1,6 +1,4 @@
{% extends "withnav_template.html" %}
{% from "components/table.html" import list_table, row, field, hidden_field_heading %}
{% from "components/page-footer.html" import page_footer %}
{% extends "views/platform-admin/_base_template.html" %}
{% block service_page_title %}
Inbound Numbers
@@ -8,7 +6,7 @@ Inbound Numbers
{% set table_headings = {
'field_headings': [
'', 'Number', 'Status', 'Service', 'Created on'
'Number', 'Status', 'Service', 'Created on'
],
'field_headings_visible': True,
'caption_visible': True
@@ -20,7 +18,7 @@ Inbound Numbers
font-weight:normal;
}
{% block maincolumn_content %}
{% block platform_admin_content %}
<div class="grid-row bottom-gutter">
<div class="column-two-thirds">
@@ -31,6 +29,7 @@ Inbound Numbers
</div>
<table class="inbound">
<col style="width:8%">
<col style="width:20%">
@@ -41,14 +40,12 @@ Inbound Numbers
<th>{{table_headings.field_headings[0]}}</th>
<th>{{table_headings.field_headings[1]}}</th>
<th>{{table_headings.field_headings[2]}}</th>
<th>{{table_headings.field_headings[3]}}</th>
</tr>
</thread>
<tbody>
{% for value in inbound_num_list.data: %}
<tr>
<th style="font-weight:normal;">{{loop.index}}</th>
<th style="font-weight:normal;">{{value.number}}</th>
<th style="font-weight:normal;">

View File

@@ -17,7 +17,8 @@
('Trial mode services', url_for('main.trial_services')),
('Providers', url_for('main.view_providers')),
('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>
<a href="{{ url }}">

View File

@@ -158,3 +158,16 @@ def test_set_text_message_sender_validation(
assert response.status_code == 200
assert page.select(".error-message")[0].text.strip() == expected_error
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'

View 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"

View File

@@ -752,19 +752,6 @@ def test_set_inbound_api_validation(
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'])
def test_cant_set_letter_contact_block_if_service_cant_send_letters(
logged_in_client,