Esempio n. 1
0
  def test_get_ref_configs(self):
    self.provider.get_ref_configs_async.return_value = ndb.Future()
    self.provider.get_ref_configs_async.return_value.set_result({
      'projects/chromium/refs/heads/master': ('dead', 'param: "master"'),
      'projects/chromium/refs/non-branch': ('beef', 'param: "ref"'),
      'projects/v8/refs/heads/master': ('aaaa', 'param: "value2"'),
      'projects/skia/refs/heads/master': ('badcoffee', 'invalid config'),
    })

    actual = config.get_ref_configs('bar.cfg', test_config_pb2.Config)
    self.assertIsInstance(
        actual['skia']['refs/heads/master'][2], config.ConfigFormatError)
    expected = {
      'chromium': {
        'refs/heads/master': (
          'dead', test_config_pb2.Config(param='master'), None),
        'refs/non-branch': (
          'beef', test_config_pb2.Config(param='ref'), None),
      },
      'v8': {
        'refs/heads/master': (
          'aaaa', test_config_pb2.Config(param='value2'), None),
      },
      'skia': {
        'refs/heads/master': (
          'badcoffee',
          None,
          actual['skia']['refs/heads/master'][2],
        ),
      }
    }
    self.assertEqual(expected, actual)
Esempio n. 2
0
  def test_get_project_configs(self):
    self.provider.get_project_configs_async.return_value = ndb.Future()
    self.provider.get_project_configs_async.return_value.set_result({
      'projects/chromium': ('deadbeef', 'param: "value"'),
      'projects/v8': ('aaaabbbb', 'param: "value2"'),
      'projects/skia': ('deadbeef', 'invalid config'),
    })

    expected = {
      'chromium': ('deadbeef', test_config_pb2.Config(param='value')),
      'v8': ('aaaabbbb', test_config_pb2.Config(param='value2')),
    }
    actual = config.get_project_configs('bar.cfg', test_config_pb2.Config)
    self.assertEqual(expected, actual)
Esempio n. 3
0
  def test_get_project_configs(self):
    self.provider.get_project_configs_async.return_value = ndb.Future()
    self.provider.get_project_configs_async.return_value.set_result({
      'projects/chromium': ('deadbeef', 'param: "value"'),
      'projects/v8': ('aaaabbbb', 'param: "value2"'),
      'projects/skia': ('badcoffee', 'invalid config'),
    })

    actual = config.get_project_configs('bar.cfg', test_config_pb2.Config)
    self.assertIsInstance(actual['skia'][2], config.ConfigFormatError)
    expected = {
      'chromium': ('deadbeef', test_config_pb2.Config(param='value'), None),
      'v8': ('aaaabbbb', test_config_pb2.Config(param='value2'), None),
      'skia': ('badcoffee', None, actual['skia'][2]),
    }
    self.assertEqual(expected, actual)
Esempio n. 4
0
 def setUp(self):
   super(ApiTestCase, self).setUp()
   self.provider = mock.Mock()
   provider_future = ndb.Future()
   provider_future.set_result(self.provider)
   self.mock(config.api, '_get_config_provider_async', lambda: provider_future)
   self.provider.get_async.return_value = ndb.Future()
   self.provider.get_async.return_value.set_result(
       ('deadbeef', test_config_pb2.Config(param='value')))
Esempio n. 5
0
  def test_get_ref_configs(self):
    self.provider.get_ref_configs_async.return_value = ndb.Future()
    self.provider.get_ref_configs_async.return_value.set_result({
      'projects/chromium/refs/heads/master': ('dead', 'param: "master"'),
      'projects/chromium/refs/non-branch': ('beef', 'param: "ref"'),
      'projects/v8/refs/heads/master': ('aaaa', 'param: "value2"'),
      'projects/skia/refs/heads/master': ('deadbeef', 'invalid config'),
    })

    expected = {
      'chromium': {
        'refs/heads/master': ('dead', test_config_pb2.Config(param='master')),
        'refs/non-branch': ('beef', test_config_pb2.Config(param='ref')),
      },
      'v8': {
        'refs/heads/master': ('aaaa', test_config_pb2.Config(param='value2')),
      },
    }
    actual = config.get_ref_configs('bar.cfg', test_config_pb2.Config)
    self.assertEqual(expected, actual)
Esempio n. 6
0
 def test_convert_unicode(self):
     text = u'param: "\U0001f604"'.encode('utf-8')
     self.assertEqual(
         common._convert_config(text, test_config_pb2.Config),
         test_config_pb2.Config(param=u'\U0001f604'),
     )
Esempio n. 7
0
 def test_get_ref_config(self):
   revision, cfg = config.get_ref_config(
       'foo', 'refs/x', 'bar.cfg', test_config_pb2.Config)
   self.assertEqual(revision, 'deadbeef')
   self.assertEqual(cfg, test_config_pb2.Config(param='value'))