本文整理汇总了Python中models.Server.query方法的典型用法代码示例。如果您正苦于以下问题:Python Server.query方法的具体用法?Python Server.query怎么用?Python Server.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Server
的用法示例。
在下文中一共展示了Server.query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_non_unique_port
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import query [as 别名]
def test_post_non_unique_port(self):
mc = MinecraftDownload.create(
'1.7.4',
'https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar'
)
self.server.key.delete()
self.log_in_admin()
self.assertEqual(0, Server.query().count())
self.assertEqual(0, Client.query().count())
response = self.post(params={
'name': 'new server',
'version': mc.version,
'memory': '1G',
'motd': 'Welcome',
'white_list': True,
'server_port': 25565,
'idle_timeout': 10,
'eula_agree': True
})
response = self.post(params={
'name': 'new server',
'version': mc.version,
'memory': '1G',
'motd': 'Welcome',
'white_list': True,
'server_port': 25565,
'idle_timeout': 10,
'eula_agree': True
})
self.assertEqual(1, Server.query().count())
self.assertEqual(1, Client.query().count())
self.assertOK(response)
示例2: test_post_idle_timeout
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import query [as 别名]
def test_post_idle_timeout(self):
mc = MinecraftDownload.create(
'1.7.4',
'https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar'
)
self.server.key.delete()
self.log_in_admin()
self.assertEqual(0, Server.query().count())
self.assertEqual(0, Client.query().count())
response = self.post(params={
'name': 'new server',
'version': mc.version,
'memory': '1G',
'motd': 'Welcome',
'white_list': True,
'server_port': 25565,
'idle_timeout': 0,
'eula_agree': True
})
self.assertEqual(1, Server.query().count())
self.assertEqual(1, Client.query().count())
server = Server.query().get()
self.assertEqual('new server', server.name)
self.assertEqual(True, server.is_gce)
self.assertEqual('1G', server.memory)
self.assertEqual(0, server.idle_timeout)
mc_properties = server.mc_properties
self.assertEqual('Welcome', mc_properties.motd)
self.assertEqual(True, mc_properties.white_list)
self.assertEqual(25565, mc_properties.server_port)
self.assertRedirects(response, '/servers/{0}'.format(server.key.urlsafe()))
示例3: test_post
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import query [as 别名]
def test_post(self):
self.server.key.delete()
self.log_in_admin()
self.assertEqual(0, Server.query().count())
self.assertEqual(0, Client.query().count())
response = self.post(params={'name': 'new server'})
self.assertEqual(1, Server.query().count())
self.assertEqual(1, Client.query().count())
server = Server.query().get()
self.assertEqual('new server', server.name)
self.assertEqual(False, server.is_gce)
self.assertRedirects(response, '/servers/{0}'.format(server.key.urlsafe()))
示例4: test_post_duplicate_none_port
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import query [as 别名]
def test_post_duplicate_none_port(self):
self.server.mc_properties.server_port = 25565
self.server.mc_properties.put()
self.log_in_admin()
self.mc = MinecraftDownload.create(
'1.7.4', 'https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar'
)
self.server.version = self.mc.version
self.server.put()
response = self.post(
params={
'name': self.server.name,
'version': self.server.version,
'memory': '1G',
'server_port': '',
'idle_timeout': 10,
'eula_agree': True
}
)
self.assertEqual(1, Server.query().count())
self.assertEqual(1, Client.query().count())
server = self.server.key.get()
server = self.server.key.get()
self.assertIsNone(server.mc_properties.server_port)
self.assertRedirects(response, '/servers/{0}'.format(server.key.urlsafe()))
示例5: get
# 需要导入模块: from models import Server [as 别名]
# 或者: from models.Server import query [as 别名]
def get(self):
results, previous_cursor, next_cursor = self.get_results_with_cursors(
User.query_all(), User.query_all_reverse(), RESULTS_PER_PAGE
)
servers = []
for server in Server.query():
servers.append(server)
instance = gce.Instance.singleton()
status = instance.get_status()
context = {'servers': servers, 'instance': instance, 'status': status}
self.render_template('admin.html', context=context)