Beispiel #1
0
  def test_cron_update_last_good_configs(self):
    self.provider.get_async(
        'services/foo', 'bar.cfg', store_last_good=True).get_result()
    self.provider.get_async(
        'services/foo', 'baz.cfg', dest_type=test_config_pb2.Config,
        store_last_good=True).get_result()

    # Will be removed.
    old_cfg = remote.LastGoodConfig(
        id='projects/old:foo.cfg',
        content_hash='aaaa',
        content='content',
        last_access_ts=datetime.datetime(2010, 1, 1))
    old_cfg.put()

    remote.cron_update_last_good_configs()

    revision, config = self.provider.get_async(
        'services/foo', 'bar.cfg', store_last_good=True).get_result()
    self.assertEqual(revision, 'aaaabbbb')
    self.assertEqual(config, 'a config')

    revision, config = self.provider.get_async(
        'services/foo', 'baz.cfg', dest_type=test_config_pb2.Config,
        store_last_good=True).get_result()
    self.assertEqual(revision, 'aaaabbbb')
    self.assertEqual(config.param, 'qux')

    baz_cfg = remote.LastGoodConfig.get_by_id(id='services/foo:baz.cfg')
    self.assertIsNotNone(baz_cfg)
    self.assertEquals(baz_cfg.content_binary, config.SerializeToString())

    self.assertIsNone(old_cfg.key.get())
Beispiel #2
0
    def test_last_good(self):
        revision, content = self.provider.get_async(
            'services/foo', 'bar.cfg', store_last_good=True).get_result()
        self.assertIsNone(revision)
        self.assertIsNone(content)

        self.assertTrue(
            remote.LastGoodConfig.get_by_id('services/foo:bar.cfg'))
        remote.LastGoodConfig(id='services/foo:bar.cfg',
                              content='a config',
                              content_hash='deadbeef',
                              revision='aaaaaaaa').put()

        revision, content = self.provider.get_async(
            'services/foo', 'bar.cfg', store_last_good=True).get_result()
        self.assertEqual(revision, 'aaaaaaaa')
        self.assertEqual(content, 'a config')

        self.assertFalse(net.json_request_async.called)
Beispiel #3
0
    def test_cron_update_last_good_configs(self):
        self.provider.get_async('services/foo',
                                'bar.cfg',
                                store_last_good=True).get_result()

        # Will be removed.
        old_cfg = remote.LastGoodConfig(id='projects/old:foo.cfg',
                                        content_hash='aaaa',
                                        content='content',
                                        last_access_ts=datetime.datetime(
                                            2010, 1, 1))
        old_cfg.put()

        remote.cron_update_last_good_configs()

        revision, content = self.provider.get_async(
            'services/foo', 'bar.cfg', store_last_good=True).get_result()
        self.assertEqual(revision, 'aaaabbbb')
        self.assertEqual(content, 'a config')
        self.assertIsNone(old_cfg.key.get())