Ejemplo n.º 1
0
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Unit tests for template.py."""

from tests.lib import test_case
from tools.regen_apis import api_def


class ApisMapTemplateTest(test_case.Base):

  def testAPIDefRepr(self):
    api_definition = api_def.APIDef(
        'fruits.orange.v1.orange_v1_client.OrangeV1',
        'fruits.orange.v1.orange_v1_messages', True)

    expected_repr = ('APIDef("fruits.orange.v1.orange_v1_client.OrangeV1", '
                     '"fruits.orange.v1.orange_v1_messages", True)')

    self.assertEquals(expected_repr, str(api_definition))


if __name__ == '__main__':
  test_case.main()
Ejemplo n.º 2
0
        self._ExpectList(expected_indexes)
        self.Run('datastore indexes list --uri')

        self.AssertOutputEquals("""\
        https://datastore.googleapis.com/v1/projects/my-test-project/indexes/indexes-0
        https://datastore.googleapis.com/v1/projects/my-test-project/indexes/indexes-1
        https://datastore.googleapis.com/v1/projects/my-test-project/indexes/indexes-2
        https://datastore.googleapis.com/v1/projects/my-test-project/indexes/indexes-3
        """,
                                normalize_space=True)

    def _ExpectList(self, indexes, project_id='my-test-project'):
        self.projects_indexes.List.Expect(
            request=self.messages.DatastoreProjectsIndexesListRequest(
                projectId=project_id),
            response=self.messages.GoogleDatastoreAdminV1ListIndexesResponse(
                indexes=indexes))

    def _MakeIndexes(self, n, project_id='my-test-project'):
        indexes = []
        for i in range(n):
            index = self.messages.GoogleDatastoreAdminV1Index(
                indexId='indexes-{}'.format(i), projectId=project_id)
            indexes.append(index)

        return indexes


if __name__ == '__main__':
    test_case.main()