本文整理匯總了Python中models.Runs._key_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Runs._key_name方法的具體用法?Python Runs._key_name怎麽用?Python Runs._key_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Runs
的用法示例。
在下文中一共展示了Runs._key_name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update_or_insert
# 需要導入模塊: from models import Runs [as 別名]
# 或者: from models.Runs import _key_name [as 別名]
def test_update_or_insert(self):
some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
some_test = Test.update_or_insert('some-test', some_branch, some_platform)
self.assertThereIsNoInstanceOf(Runs)
runs = Runs.update_or_insert(some_branch, some_platform, some_test)
self.assertOnlyInstance(runs)
self.assertEqual(runs.json_runs, '')
self.assertEqual(runs.json_averages, '')
self.assertEqual(runs.json_min, None)
self.assertEqual(runs.json_max, None)
old_memcache_value = memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id))
self.assertTrue(old_memcache_value)
runs.delete()
self.assertThereIsNoInstanceOf(Runs)
builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
runs = Runs.update_or_insert(some_branch, some_platform, some_test)
self.assertOnlyInstance(runs)
self.assertTrue(runs.json_runs.startswith('[5, [4, 0, 100, null],'))
self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0})
self.assertEqual(runs.json_min, 50.0)
self.assertEqual(runs.json_max, 50.0)
self.assertNotEqual(memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id)), old_memcache_value)
示例2: test_json_by_ids
# 需要導入模塊: from models import Runs [as 別名]
# 或者: from models.Runs import _key_name [as 別名]
def test_json_by_ids(self):
some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
some_test = Test.update_or_insert('some-test', some_branch, some_platform)
self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
runs = Runs.update_or_insert(some_branch, some_platform, some_test)
runs_json = runs.to_json()
key_name = Runs._key_name(some_branch.id, some_platform.id, some_test.id)
self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), runs_json)
self.assertEqual(memcache.get(key_name), runs_json)
memcache.set(key_name, 'blah')
self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), 'blah')
memcache.delete(key_name)
self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), runs_json)
self.assertEqual(memcache.get(key_name), runs_json)