本文整理汇总了Python中models.robot.Robot.put方法的典型用法代码示例。如果您正苦于以下问题:Python Robot.put方法的具体用法?Python Robot.put怎么用?Python Robot.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.robot.Robot
的用法示例。
在下文中一共展示了Robot.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTeamHistoryRobotsApiController
# 需要导入模块: from models.robot import Robot [as 别名]
# 或者: from models.robot.Robot import put [as 别名]
class TestTeamHistoryRobotsApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<team_key:>', ApiTeamHistoryRobotsController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc1124",
name="UberBots",
team_number=1124,
nickname="UberBots"
)
self.robot = Robot(
id="frc1124_2015",
team=self.team.key,
year=2015,
robot_name="Orion"
)
self.team.put()
self.robot.put()
def tearDown(self):
self.testbed.deactivate()
def testRobotApi(self):
response = self.testapp.get('/frc1124', headers={"X-TBA-App-Id": "tba-tests:team_list-controller-test:v01"})
robot_dict = json.loads(response.body)
self.assertTrue("2015" in robot_dict)
robot = robot_dict["2015"]
self.assertEqual(robot["key"], "frc1124_2015")
self.assertEqual(robot["team_key"], "frc1124")
self.assertEqual(robot["year"], 2015)
self.assertEqual(robot["name"], "Orion")
示例2: process_form
# 需要导入模块: from models.robot import Robot [as 别名]
# 或者: from models.robot.Robot import put [as 别名]
def process_form(self, mid=None):
if mid:
robot = Robot.get_by_id(int(mid), parent=self.current_user.key)
else:
robot = Robot(parent=self.current_user.key)
form = forms.RobotForm(self.request.POST, obj=robot)
if form.validate():
# TODO better populate object
robot.name = form.data['name']
robot.schedule = form.data['schedule']
robot.rps = form.data['rps']
robot.timeout = form.data['timeout']
robot.urlsource = URLSource.factory(form.urlsource.form.data)
key = robot.put()
return self.redirect_to('robot-view', mid=key.id())
self.render_response('robot/form.html', form=form, mid=mid, robot=robot)
示例3: test_list_returns_one
# 需要导入模块: from models.robot import Robot [as 别名]
# 或者: from models.robot.Robot import put [as 别名]
def test_list_returns_one(self):
groupkey = ndb.Key('_', '_')
robot = Robot(parent=groupkey, name='_', schedule=SCHEDULES.keys()[0])
robot.put()
self.assertEqual(Robot.list(ancestor=groupkey), [robot])