本文整理汇总了Python中app_dashboard_data.AppDashboardData.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python AppDashboardData.get_by_id方法的具体用法?Python AppDashboardData.get_by_id怎么用?Python AppDashboardData.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app_dashboard_data.AppDashboardData
的用法示例。
在下文中一共展示了AppDashboardData.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rebuild_dash_layout_settings_dict_default
# 需要导入模块: from app_dashboard_data import AppDashboardData [as 别名]
# 或者: from app_dashboard_data.AppDashboardData import get_by_id [as 别名]
def test_rebuild_dash_layout_settings_dict_default(self):
# slip in some fake users
self.setupUserInfoMocks()
# mock out the App Engine Users API
self.setupUsersAPIMocks()
data1 = AppDashboardData()
user1 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user2 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user3 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user4 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
# First call, not logged in.
self.assertEqual({}, data1.rebuild_dash_layout_settings_dict(email=None))
# First user: [email protected], upload=True, cloud_admin=True
self.assertEqual(self.user_info1_cloud_admin_dict, self.flatten_dash_layout(
data1.rebuild_dash_layout_settings_dict(
email=user1.email)))
# Second user: [email protected], upload=True, cloud_admin=False
self.assertEqual(self.user_info2_can_upload_apps_dict,
self.flatten_dash_layout(
data1.rebuild_dash_layout_settings_dict(
email=user2.email)))
# Third user: [email protected], upload=False, cloud_admin=False
self.assertEqual(self.user_info3_cannot_upload_apps_dict,
self.flatten_dash_layout(
data1.rebuild_dash_layout_settings_dict(
email=user3.email)))
# Fourth user: [email protected], upload=False, cloud_admin=False
self.assertEqual(self.user_info4_cannot_upload_and_owns_no_apps_dict,
self.flatten_dash_layout(
data1.rebuild_dash_layout_settings_dict(
email=user4.email)))
示例2: test_rebuild_dash_layout_settings_dict_custom
# 需要导入模块: from app_dashboard_data import AppDashboardData [as 别名]
# 或者: from app_dashboard_data.AppDashboardData import get_by_id [as 别名]
def test_rebuild_dash_layout_settings_dict_custom(self):
# slip in some fake users
self.setupUserInfoMocks()
# mock out the App Engine Users API
self.setupUsersAPIMocks()
data1 = AppDashboardData()
user1 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user2 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user3 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user4 = data1.get_by_id(app_dashboard_data.UserInfo, "[email protected]")
user_setting = {
"nav":["debugging_monitoring", "appscale_management", "app_management",
"invalid_key"],
"panel":["cloud_stats","database_stats","upload_app","app_console",
"memcache_stats"]
}
# First user: [email protected], upload=True, cloud_admin=True
user1_should_return = {
"nav":["debugging_monitoring", "appscale_management", "app_management"],
"panel":["cloud_stats","database_stats","upload_app","app_console",
"memcache_stats"]
}
self.assertEqual(self.flatten_dash_layout(
data1.set_dash_layout_settings(values=user_setting, user_info=user1)),
user1_should_return)
self.assertEqual(user1_should_return,
self.flatten_dash_layout(data1.rebuild_dash_layout_settings_dict(
email=user1.email)))
# Second user: [email protected], upload=True, cloud_admin=False
user_setting = {
"nav":["debugging_monitoring", "appscale_management", "app_management",
"invalid_key"],
"panel":["cloud_stats","database_stats","upload_app","app_console",
"memcache_stats"]
}
user2_should_return = {
"nav":["debugging_monitoring", "app_management"],
"panel":["upload_app","app_console"]
}
self.assertEqual(self.flatten_dash_layout(
data1.set_dash_layout_settings(values=user_setting, user_info=user2)),
user2_should_return)
self.assertEqual(user2_should_return,
self.flatten_dash_layout(data1.rebuild_dash_layout_settings_dict(
email=user2.email)))
# Third user: [email protected], upload=False, cloud_admin=False
user_setting = {
"nav":["debugging_monitoring", "appscale_management", "app_management",
"invalid_key"],
"panel":["cloud_stats","database_stats","upload_app","app_console",
"memcache_stats"]
}
user3_should_return = {
"nav":["debugging_monitoring"],
"panel":["upload_app","app_console"]
}
self.assertEqual(self.flatten_dash_layout(
data1.set_dash_layout_settings(values=user_setting, user_info=user3)),
user3_should_return)
self.assertEqual(user3_should_return,
self.flatten_dash_layout(data1.rebuild_dash_layout_settings_dict(
email=user3.email)))
# Fourth user: [email protected], upload=False, cloud_admin=False
user_setting = {
"nav":["debugging_monitoring", "appscale_management", "app_management",
"invalid_key"],
"panel":["cloud_stats","database_stats","upload_app","app_console",
"memcache_stats"]
}
user4_should_return = {
"nav":[],
"panel":["upload_app","app_console"]
}
self.assertEqual(self.flatten_dash_layout(
data1.set_dash_layout_settings(values=user_setting, user_info=user4)),
user4_should_return)
self.assertEqual(user4_should_return,
self.flatten_dash_layout(data1.rebuild_dash_layout_settings_dict(
email=user4.email)))