class AvailabePhoneNumbersTest(unittest.TestCase):

    def setUp(self):
        self.resource = AvailablePhoneNumbers("http://api.telapi.com",
                                              ("user", "pass"), Mock())

    def test_get(self):
        with self.assertRaises(TelapiException):
            self.resource.get("PN123")

    def test_list(self):
        request = Mock()
        request.return_value = (Mock(), {"available_phone_numbers": []})
        self.resource.request = request

        self.resource.list()

        uri = "http://api.telapi.com/AvailablePhoneNumbers/US/Local"
        request.assert_called_with("GET", uri, params={})

    def test_load_instance(self):
        instance = self.resource.load_instance({"hey": "you"})
        self.assertIsInstance(instance.parent, Mock)
        self.assertEquals(instance.hey, "you")
 def setUp(self):
     self.resource = AvailablePhoneNumbers("http://api.telapi.com",
                                           ("user", "pass"), Mock())