Example #1
0
def test_update_null_parameters(line):
    url = confd.lines_sip(line['id'])

    response = url.put(callerid=None)
    response.assert_updated()

    response = url.get()
    assert_that(response.item['callerid'], none())
Example #2
0
def test_put_errors(line):
    line_put = confd.lines_sip(line['id']).put

    yield s.check_missing_required_field_returns_error, line_put, 'context'
    yield s.check_bogus_field_returns_error, line_put, 'context', 123
    yield s.check_bogus_field_returns_error, line_put, 'device_slot', '1'
    yield s.check_bogus_field_returns_error, line_put, 'callerid', 'invalidcallerid'
    yield s.check_bogus_field_returns_error, line_put, 'secret', 123
    yield s.check_bogus_field_returns_error, line_put, 'username', 123
Example #3
0
def test_get(line):
    expected = has_entries({'username': has_length(8),
                            'secret': has_length(8),
                            'context': config.CONTEXT,
                            'device_slot': 1,
                            'provisioning_extension': has_length(6),
                            'callerid': none(),
                            })

    response = confd.lines_sip(line['id']).get()
    assert_that(response.item, expected)
Example #4
0
def test_post_errors():
    empty_post = confd.lines_sip.post
    line_post = confd.lines_sip(context=config.CONTEXT, device_slot=1).post

    yield s.check_missing_required_field_returns_error, empty_post, 'context'

    yield s.check_bogus_field_returns_error, line_post, 'context', 123
    yield s.check_bogus_field_returns_error, line_post, 'device_slot', 'slot'
    yield s.check_bogus_field_returns_error, line_post, 'callerid', 'invalidcallerid'
    yield s.check_bogus_field_returns_error, line_post, 'secret', [{}]
    yield s.check_bogus_field_returns_error, line_post, 'username', [{}]
Example #5
0
def test_update_all_parameters_on_line(line, context):
    url = confd.lines_sip(line['id'])
    expected = has_entries({'context': context['name'],
                            'device_slot': 2,
                            'callerid': u'"Mamàsta Michel" <2000>',
                            'provisioning_extension': '234567',
                            'secret': 'newsecret',
                            'username': '******'})

    response = url.put(context=context['name'],
                       device_slot=2,
                       callerid=u'"Mamàsta Michel" <2000>',
                       provisioning_extension='234567',
                       secret='newsecret',
                       username='******')
    response.assert_updated()

    response = url.get()
    assert_that(response.item, expected)
Example #6
0
def test_edit_line_with_fake_context(line):
    response = confd.lines_sip(line['id']).put(context='fakecontext',
                                                 device_slot=1)
    response.assert_match(400, e.not_found('Context'))
Example #7
0
def delete_line(line_id, check=False):
    response = confd.lines_sip(line_id).delete()
    if check:
        response.assert_ok()
Example #8
0
def test_delete_errors(line):
    line_url = confd.lines_sip(line['id'])
    line_url.delete()
    yield s.check_resource_not_found, line_url.get, 'Line'
Example #9
0
def test_get_errors():
    fake_line_get = confd.lines_sip(999999).get
    yield s.check_resource_not_found, fake_line_get, 'Line'
Example #10
0
def test_delete_line(line):
    response = confd.lines_sip(line['id']).delete()
    response.assert_deleted()
Example #11
0
def test_update_line_with_fake_context(line):
    response = confd.lines_sip(line['id']).put(context='fakecontext')
    response.assert_match(400, e.not_found('Context'))
Example #12
0
def delete_line(line_id, check=False):
    response = confd.lines_sip(line_id).delete()
    if check:
        response.assert_ok()