예제 #1
0
def create():
    data = document.parse(request)
    voicemail = formatter.dict_to_model(data)
    voicemail = voicemail_services.create(voicemail)
    result = formatter.to_api(voicemail)
    location = url_for('.get', voicemailid=voicemail.id)
    return make_response(result, 201, {'Location': location})
예제 #2
0
    def test_create(self, voicemail_dao_create, voicemail_notifier_created, validate_create):
        name = 'voicemail'
        number = '42'
        context = 'default'

        voicemail = Voicemail(name=name,
                              number=number,
                              context=context)

        voicemail_dao_create.return_value = voicemail

        result = voicemail_services.create(voicemail)

        validate_create.assert_called_once_with(voicemail)
        voicemail_dao_create.assert_called_once_with(voicemail)
        self.assertEquals(type(result), Voicemail)
        voicemail_notifier_created.assert_called_once_with(voicemail)