本文整理汇总了Python中flashcardapp.datacontroller.DataController.addContainerToMyCards方法的典型用法代码示例。如果您正苦于以下问题:Python DataController.addContainerToMyCards方法的具体用法?Python DataController.addContainerToMyCards怎么用?Python DataController.addContainerToMyCards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flashcardapp.datacontroller.DataController
的用法示例。
在下文中一共展示了DataController.addContainerToMyCards方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_addContainerToMyCardsWithAutoUpdates
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addContainerToMyCards [as 别名]
def test_addContainerToMyCardsWithAutoUpdates(self):
"""
Steps this test will run:
1.
.
.
.
?.
"""
cntName = "Shared Greetings"
toClassId = 1
fromClassId = 6
cntToGetId = 5
numofcontainers = 4
dc = DataController()
toClass = Class.objects.get(pk=toClassId)
toCopyContainer = Container.objects.get(pk=cntToGetId)
result = dc.addContainerToMyCards(toCopyContainer.Id, toClass.Id, True)
data = json.loads(result)
self.assertTrue(data['added'], data['message'])
self.assertEqual(len(toClass.container_set.all()), numofcontainers)
self.assertIsNotNone(toClass.container_set.get(title=cntName))
copiedContainer = toClass.container_set.get(title=cntName)
self.assertEqual(copiedContainer.Id, toCopyContainer.Id)
self.assertNotEqual(copiedContainer.owner, toClass.user)
self.assertEqual(len(copiedContainer.box_set.all()), len(toCopyContainer.box_set.all()))
self.assertEqual(copiedContainer, toCopyContainer)
self.assertIn(toClass, copiedContainer.classes.all())
self.assertIn(toClass, toCopyContainer.classes.all())
示例2: addContainerToMyCards
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addContainerToMyCards [as 别名]
def addContainerToMyCards(request, containerId, classId, isAutoUpdated):
'''Ajax wrapper method for the DataController method 'addContainerToMyCards'
*Takes*
**containerId** - Id of the shared container to copy.
**classId** - Id of the class to copy the container to.
**isAutoUpdated** - Whether the container will be auto updated or not.
*Returns*
A json string declaring success or failure
See the DataController documentation for more information.
'''
dc = DataController()
return dc.addContainerToMyCards(containerId, classId, isAutoUpdated)
示例3: test_addContainerToMyCardsWithoutAutoUpdates
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addContainerToMyCards [as 别名]
def test_addContainerToMyCardsWithoutAutoUpdates(self):
"""
Steps this test will run:
1.
.
.
.
?.
"""
cntName = "Shared Greetings"
toClassId = 1 #'German 101' class of testuser
fromClassId = 6 #'German 101' class of jake (superuser)
cntToGetId = 5 #'Shared Greetings' container of jake
numofcontainers = 4
dc = DataController()
toClass = Class.objects.get(pk=toClassId)
toCopyContainer = Container.objects.get(pk=cntToGetId)
#pdb.set_trace()
result = dc.addContainerToMyCards(toCopyContainer.Id, toClass.Id, False)
data = json.loads(result)
self.assertTrue(data['added'], data['message'])
self.assertEqual(len(toClass.container_set.all()), numofcontainers)
self.assertIsNotNone(toClass.container_set.get(title=cntName))
copiedContainer = toClass.container_set.get(title=cntName)
#Make sure containers aren't the same
self.assertNotEqual(copiedContainer, toCopyContainer)
self.assertNotEqual(copiedContainer.Id, toCopyContainer.Id)
#Check the owners/users of the containers/classes
self.assertNotEqual(toCopyContainer.owner, toClass.user)
self.assertNotEqual(copiedContainer.owner, toCopyContainer.owner)
self.assertEqual(copiedContainer.owner, toClass.user)
#Check the classes that the containers are related too.
self.assertIn(toClass, copiedContainer.classes.all())
self.assertNotIn(toClass, toCopyContainer.classes.all())
#Make sure the privacy settings are right
self.assertTrue(copiedContainer.isPrivate)
self.assertFalse(toCopyContainer.isPrivate)
#Make sure both containers have the same number of boxes
self.assertEqual(len(copiedContainer.box_set.all()), len(toCopyContainer.box_set.all()))
toCopyBoxes = toCopyContainer.box_set.all()
copiedBoxes = copiedContainer.box_set.all()
for i in range(len(copiedBoxes)):
tcBox = toCopyBoxes[i]
cBox = copiedBoxes[i]
self.assertNotEqual(tcBox.Id, cBox.Id)
self.assertEqual(tcBox.title, cBox.title)
self.assertEqual(len(cBox.containers.all()), 1)
self.assertEqual(len(tcBox.containers.all()), 1)
self.assertEqual(len(tcBox.flashcard_set.all()), len(cBox.flashcard_set.all()))
tcFlashcards = tcBox.flashcard_set.all()
cFlashcards = cBox.flashcard_set.all()
for j in range(len(cFlashcards)):
tcFlashcard = tcFlashcards[j]
cFlashcard = cFlashcards[j]
self.assertEqual(tcFlashcard.Id, cFlashcard.Id)