本文整理汇总了Python中models.media.Media.put方法的典型用法代码示例。如果您正苦于以下问题:Python Media.put方法的具体用法?Python Media.put怎么用?Python Media.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.media.Media
的用法示例。
在下文中一共展示了Media.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTeamMediaApiController
# 需要导入模块: from models.media import Media [as 别名]
# 或者: from models.media.Media import put [as 别名]
class TestTeamMediaApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<team_key:>/<year:>', ApiTeamMediaController, 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()
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc254",
name="very long name",
team_number=254,
nickname="Teh Chezy Pofs",
address="Greenville, SC, USA"
)
self.team.put()
self.cdmedia = Media(
key=ndb.Key('Media', 'cdphotothread_39894'),
details_json=u'{"image_partial": "fe3/fe38d320428adf4f51ac969efb3db32c_l.jpg"}',
foreign_key=u'39894',
media_type_enum=1,
references=[ndb.Key('Team', 'frc254')],
year=2014)
self.cdmedia.put()
self.cddetails = dict()
self.cddetails["image_partial"] = "fe3/fe38d320428adf4f51ac969efb3db32c_l.jpg"
self.ytmedia = Media(
key=ndb.Key('Media', 'youtube_aFZy8iibMD0'),
details_json=None,
foreign_key=u'aFZy8iibMD0',
media_type_enum=0,
references=[ndb.Key('Team', 'frc254')],
year=2014)
self.ytmedia.put()
def tearDown(self):
self.testbed.deactivate()
def testTeamMediaApi(self):
response = self.testapp.get('/frc254/2014', headers={"X-TBA-App-Id": "tba-tests:team_media-controller-test:v01"})
media = json.loads(response.body)
self.assertEqual(len(media), 2)
cd = media[0]
self.assertEqual(cd["type"], "cdphotothread")
self.assertEqual(cd["foreign_key"], "39894")
self.assertEqual(cd["details"], self.cddetails)
yt = media[1]
self.assertEqual(yt["type"], "youtube")
self.assertEqual(yt["foreign_key"], "aFZy8iibMD0")
self.assertEqual(yt["details"], {})