当前位置: 首页>>代码示例>>Python>>正文


Python DataController.addContainerToMyCards方法代码示例

本文整理汇总了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())
开发者ID:hrusza01,项目名称:Flash-Card-Website-2013,代码行数:37,代码来源:tests.py

示例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)
开发者ID:hrusza01,项目名称:Flash-Card-Website-2013,代码行数:16,代码来源:ajax.py

示例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)
开发者ID:hrusza01,项目名称:Flash-Card-Website-2013,代码行数:72,代码来源:tests.py


注:本文中的flashcardapp.datacontroller.DataController.addContainerToMyCards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。