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


Python DataController.addContainer方法代码示例

本文整理汇总了Python中flashcardapp.datacontroller.DataController.addContainer方法的典型用法代码示例。如果您正苦于以下问题:Python DataController.addContainer方法的具体用法?Python DataController.addContainer怎么用?Python DataController.addContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flashcardapp.datacontroller.DataController的用法示例。


在下文中一共展示了DataController.addContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_addContainer

# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addContainer [as 别名]
    def test_addContainer(self):
        """
        Steps this test will run:

        1. Creates a new DataController
        2. Creates a new json string representing the data of a container based
           on the specifications of the DataController's addContainer method.
        3. Passes the json string to the DataController's addContainer 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()
        cName = "Test Container"
        clsKey = 1
        numofcontainers = 4
        data = {"title":cName, "classId":clsKey}
        resultStr = dc.addContainer(data, self.user)
        result = json.loads(resultStr)
        self.assertTrue('saved' in result)
        self.assertTrue(result['saved'], result['message'])

        #Check that the associatation was actually made
        clist = Container.objects.filter(classes__Id=clsKey)
        self.assertEqual(len(clist), numofcontainers)

        cls = Class.objects.get(pk=clsKey)
        cnt = Container.objects.get(title=cName)

        self.assertIn(cls, cnt.classes.all())
        self.assertTrue(cnt in cls.container_set.all(), "The container is not associated with the class.")
开发者ID:hrusza01,项目名称:Flash-Card-Website-2013,代码行数:33,代码来源:tests.py

示例2: addContainer

# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import addContainer [as 别名]
def addContainer(request, ContainerData):
    ''' Ajax wrapper for the DataController function 'addContainer'

    *Takes*
      A dictionary representing a container
    *Returns*
      A json string declaring saved data success or failure

    See the DataController documentation for more information
    '''
    dc = DataController()
    return dc.addContainer(ContainerData, request.user)
开发者ID:hrusza01,项目名称:Flash-Card-Website-2013,代码行数:14,代码来源:ajax.py


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