本文整理匯總了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])