本文整理汇总了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)