Example #1
0
    def test_get_mapping(self):
        storage.ConfigSet(id="services/x", latest_revision="deadbeef", location="http://x").put()
        storage.ConfigSet(id="services/y", latest_revision="deadbeef", location="http://y").put()

        self.assertEqual(storage.get_mapping_async().get_result(), {"services/x": "http://x", "services/y": "http://y"})
        self.assertEqual(storage.get_mapping_async("services/x").get_result(), {"services/x": "http://x"})
        self.assertEqual(storage.get_mapping_async("services/z").get_result(), {"services/z": None})
Example #2
0
  def test_get_mapping(self):
    storage.ConfigSet(
        id='services/x', latest_revision='deadbeef', location='http://x').put()
    storage.ConfigSet(
        id='services/y', latest_revision='deadbeef', location='http://y').put()

    self.assertEqual(
        storage.get_mapping_async().get_result(),
        {'services/x':'http://x', 'services/y':'http://y'}
    )
    self.assertEqual(
        storage.get_mapping_async('services/x').get_result(),
        {'services/x':'http://x'}
    )
    self.assertEqual(
        storage.get_mapping_async('services/z').get_result(),
        {'services/z':None}
    )
Example #3
0
  def get_mapping(self, request):
    """Returns config-set mapping, one or all."""
    if request.config_set and not self.can_read_config_set(request.config_set):
      raise endpoints.ForbiddenException()

    res = self.GetMappingResponseMessage()
    mapping = storage.get_mapping_async(
        config_set=request.config_set).get_result()
    for config_set, location in sorted(mapping.iteritems()):
      if self.can_read_config_set(config_set):
        res.mappings.append(
            res.Mapping(config_set=config_set, location=location))
    return res