def test_delete_and_remove(self, m):
        integration_id = 'P1ONR10'
        service_url = '{0}/services/{1}'.format(
            self.base_url,
            self.service_id,
        )
        integration_data = self.integration_data[0]

        integration_url = '{0}/integrations/{1}'.format(
            service_url,
            integration_data['id']
        )

        m.register_uri(
            'GET',
            integration_url,
            json={'integration': integration_data},
            complete_qs=False
        )

        integration = Integration.fetch(integration_id,
                                        service=self.service_id)

        with self.assertRaises(InvalidEndpoint):
            Integration.delete(integration_id)

        with self.assertRaises(InvalidEndpointOperation):
            integration.remove()
    def test_fetch_with_service(self, m):
        # setup mocked request uris
        integration_id = 'P1ONR10'
        service_url = '{0}/services/{1}'.format(
            self.base_url,
            self.service_id,
        )

        integration_data = self.integration_data[0]

        integration_url = '{0}/integrations/{1}'.format(
            service_url, integration_data['id'])

        m.register_uri('GET',
                       integration_url,
                       json={'integration': integration_data},
                       complete_qs=False)

        m.register_uri('GET',
                       service_url,
                       json=self.service_data,
                       complete_qs=False)

        service = Service.fetch(self.service_id, api_key=self.api_key)
        integration = Integration.fetch(integration_id, service=service)
        self.assertDictEqual(integration._data, integration_data)
    def test_fetch_with_service(self, m):
        # setup mocked request uris
        integration_id = 'P1ONR10'
        service_url = '{0}/services/{1}'.format(
            self.base_url,
            self.service_id,
        )

        integration_data = self.integration_data[0]

        integration_url = '{0}/integrations/{1}'.format(
            service_url,
            integration_data['id']
        )

        m.register_uri(
            'GET',
            integration_url,
            json={'integration': integration_data},
            complete_qs=False
        )

        m.register_uri(
            'GET',
            service_url,
            json=self.service_data,
            complete_qs=False
        )

        service = Service.fetch(self.service_id, api_key=self.api_key)
        integration = Integration.fetch(integration_id, service=service)
        self.assertDictEqual(integration._data, integration_data)
    def test_delete_and_remove(self, m):
        integration_id = 'P1ONR10'
        service_url = '{0}/services/{1}'.format(
            self.base_url,
            self.service_id,
        )
        integration_data = self.integration_data[0]

        integration_url = '{0}/integrations/{1}'.format(
            service_url, integration_data['id'])

        m.register_uri('GET',
                       integration_url,
                       json={'integration': integration_data},
                       complete_qs=False)

        integration = Integration.fetch(integration_id,
                                        service=self.service_id)

        with self.assertRaises(InvalidEndpoint):
            Integration.delete(integration_id)

        with self.assertRaises(InvalidEndpointOperation):
            integration.remove()