本文整理汇总了Python中flashcardapp.datacontroller.DataController.addBox方法的典型用法代码示例。如果您正苦于以下问题:Python DataController.addBox方法的具体用法?Python DataController.addBox怎么用?Python DataController.addBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flashcardapp.datacontroller.DataController
的用法示例。
在下文中一共展示了DataController.addBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_addBox
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addBox [as 别名]
def test_addBox(self):
"""
Steps this test will run:
1. Creates a new DataController
2. Creates a new json string representing the data of a box based
on the specifications of the DataController's addBox method.
3. Passes the json string to the DataController's addBox method
and gets the result of the method (response).
4. Asserts that there is a 'saved' key in the response.
5. Asserts that the value of 'saved' is True.
"""
dc = DataController()
boxTitle = "Test Box"
cntId = 1
data = {"title":boxTitle, "containerId":cntId}
resultStr = dc.addBox(data)
result = json.loads(resultStr)
self.assertTrue('saved' in result)
self.assertTrue(result['saved'], result['message'])
#Check the association was done correctly
box = Box.objects.get(title=boxTitle)
cnt = Container.objects.get(pk=cntId)
self.assertIn(cnt, box.containers.all())
self.assertIn(box, cnt.box_set.all())
示例2: addBox
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addBox [as 别名]
def addBox(request, BoxData):
''' Ajax wrapper for the DataController function 'addBox'
*Takes*
A dictionary representing a box
*Returns*
A json string declaring saved data success or failure
See the DataController documentation for more information
'''
dc = DataController()
return dc.addBox(BoxData)