當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。