11import unittest
22
3- from mock import Mock
4- from twilio .rest .resources import Applications
3+ from mock import Mock , patch
4+
5+ from twilio .rest .resources import Applications , Application
56
67
78class ApplicationsTest (unittest .TestCase ):
89 def setUp (self ):
910 self .parent = Mock ()
1011 self .resource = Applications ("http://api.twilio.com" , ("user" , "pass" ))
1112
12- def test_create_appliation_sms_url_method (self ):
13+ def test_create_application_sms_url_method (self ):
1314 self .resource .create_instance = Mock ()
1415 self .resource .create (sms_method = "hey" )
1516 self .resource .create_instance .assert_called_with ({"sms_method" : "hey" })
1617
17- def test_create_appliation_sms_url (self ):
18+ def test_create_application_sms_url (self ):
1819 self .resource .create_instance = Mock ()
1920 self .resource .create (sms_url = "hey" )
2021 self .resource .create_instance .assert_called_with ({"sms_url" : "hey" })
2122
22- def test_update_appliation_sms_url_method (self ):
23+ def test_update_application_sms_url_method (self ):
2324 self .resource .update_instance = Mock ()
2425 self .resource .update ("123" , sms_method = "hey" )
2526 self .resource .update_instance .assert_called_with (
2627 "123" , {"sms_method" : "hey" })
2728
28- def test_update_appliation_sms_url (self ):
29+ def test_update_application_sms_url (self ):
2930 self .resource .update_instance = Mock ()
3031 self .resource .update ("123" , sms_url = "hey" )
3132 self .resource .update_instance .assert_called_with (
@@ -52,3 +53,16 @@ def test_create(self):
5253
5354 uri = "http://api.twilio.com/Applications"
5455 request .assert_called_with ("POST" , uri , data = {"FriendlyName" : "hey" })
56+
57+ @patch ("twilio.rest.resources.base.Resource.request" )
58+ def test_delete (self , req ):
59+ """ Deleting an application should work """
60+ resp = Mock ()
61+ resp .content = ""
62+ resp .status_code = 204
63+ req .return_value = resp , {}
64+
65+ app = Application (self .resource , "AP123" )
66+ app .delete ()
67+ uri = "http://api.twilio.com/Applications/AP123"
68+ req .assert_called_with ("DELETE" , uri )
0 commit comments