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


Python ProjectFactory.save方法代码示例

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


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

示例1: TestProjectStatusUpdate

# 需要导入模块: from bluebottle.test.factory_models.projects import ProjectFactory [as 别名]
# 或者: from bluebottle.test.factory_models.projects.ProjectFactory import save [as 别名]
class TestProjectStatusUpdate(BluebottleTestCase):
    """
    save() automatically updates some fields, specifically
    the status field. Make sure it picks the right one
    """

    def setUp(self):
        super(TestProjectStatusUpdate, self).setUp()

        self.init_projects()

        self.theme = ProjectThemeFactory(slug='test-theme')
        self.project = ProjectFactory(theme=self.theme)
        self.task = TaskFactory(project=self.project)

        self.survey = SurveyFactory(link='https://example.com/survey/1/')

    def test_survey_url(self):
        url = urlparse(
            Survey.url(self.task)
        )
        query = parse_qs(url.query)

        self.assertEqual(url.netloc, 'example.com')
        self.assertEqual(query['theme'], [self.theme.slug])
        self.assertEqual(query['project_id'], [str(self.project.id)])
        self.assertEqual(query['task_id'], [str(self.task.id)])
        self.assertEqual(query['user_type'], ['task_member'])

    def test_survey_url_no_survey(self):
        self.survey.delete()

        self.assertIsNone(Survey.url(self.task))

    def test_survey_url_project(self):
        url = urlparse(
            Survey.url(self.project)
        )
        query = parse_qs(url.query)

        self.assertEqual(url.netloc, 'example.com')
        self.assertEqual(query['theme'], [self.theme.slug])
        self.assertEqual(query['project_id'], [str(self.project.id)])
        self.assertTrue('task_id' not in query)

    def test_survey_url_user_type(self):
        url = urlparse(
            Survey.url(self.task, user_type='initiator'),
        )
        query = parse_qs(url.query)

        self.assertEqual(url.netloc, 'example.com')
        self.assertEqual(query['theme'], [self.theme.slug])
        self.assertEqual(query['project_id'], [str(self.project.id)])
        self.assertEqual(query['task_id'], [str(self.task.id)])
        self.assertEqual(query['user_type'], ['initiator'])

    def test_survey_url_no_celebration(self):
        self.project.celebrate_results = False
        self.project.save()

        self.assertIsNone(Survey.url(self.project))
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:64,代码来源:test_unit.py


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