예제 #1
0
    def test_forseti_unsupported_valid_version_is_ok(
            self,
            mock_discovery_build):
        """Test that Forseti-supported API with unsupported valid version is ok.

        Setup:
            * Pick one of the supported APIs.
            * Pick a valid version (not officially supported by Forseti).
            * Instantiate the Base Client with the API name and version.

        Expect:
            * The resulting API client service has the same API name and
              version as the supported API.
            * Unsupported version will call LOGGER.warn().
        """

        api_name = 'cloudresourcemanager'
        provided_version = 'v1beta1'
        mock_credentials = mock.MagicMock()
        _base_client.LOGGER = mock.MagicMock()

        client = _base_client.BaseClient({},
                                         credentials=mock_credentials,
                                         api_name=api_name,
                                         version=provided_version)

        self.assertEqual((api_name, provided_version),
                         (client.name, client.version))

        self.assertEqual(1, _base_client.LOGGER.warn.call_count)
예제 #2
0
    def test_forseti_supported_api_is_ok(self, mock_discovery_build):
        """Test that Forseti-supported API in BaseClient.__init__() works.

        Setup:
            * Pick one of the supported APIs.
            * Instantiate the Base Client with just the API name.

        Expect:
            * The resulting API client service has the same API name and
              version as the supported API.
        """

        api_name = self.supported_apis.keys()[0]
        supported_api = self.supported_apis[api_name]
        mock_credentials = mock.MagicMock()

        client = _base_client.BaseClient(credentials=mock_credentials,
                                         api_name=api_name)

        self.assertEqual((api_name, supported_api['version']),
                         (client.name, client.version))