コード例 #1
0
ファイル: storage_test.py プロジェクト: pombreda/luci-py
    def put_file(self, config_set, revision, path, content):
        confg_set_key = storage.ConfigSet(id=config_set,
                                          latest_revision=revision).put()
        rev_key = storage.Revision(id=revision, parent=confg_set_key).put()

        content_hash = storage.compute_hash(content)
        storage.File(id=path, parent=rev_key, content_hash=content_hash).put()
        storage.Blob(id=content_hash, content=content).put()
コード例 #2
0
    def test_get_config_by_hash(self):
        expected = {'deadbeef': None}
        actual = storage.get_configs_by_hashes_async(['deadbeef']).get_result()
        self.assertEqual(expected, actual)

        storage.Blob(id='deadbeef', content='content').put()
        expected = {'deadbeef': 'content'}
        actual = storage.get_configs_by_hashes_async(['deadbeef']).get_result()
        self.assertEqual(expected, actual)
コード例 #3
0
  def put_file(self, config_set, revision, path, content):
    confg_set_key = storage.ConfigSet(
        id=config_set,
        location='https://x.com',

        latest_revision=revision,
        latest_revision_url='https://x.com/+/%s' % revision,
        latest_revision_time=datetime.datetime(2016, 1, 1),
        latest_revision_committer_email='*****@*****.**',
    ).put()
    rev_key = storage.Revision(id=revision, parent=confg_set_key).put()

    content_hash = storage.compute_hash(content)
    storage.File(id=path, parent=rev_key, content_hash=content_hash).put()
    storage.Blob(id=content_hash, content=content).put()
コード例 #4
0
 def test_get_config_by_hash(self):
   self.assertIsNone(storage.get_config_by_hash_async('deadbeef').get_result())
   storage.Blob(id='deadbeef', content='content').put()
   self.assertEqual(
       storage.get_config_by_hash_async('deadbeef').get_result(), 'content')