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


Python Job.full_clean方法代码示例

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


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

示例1: JobModelTest

# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import full_clean [as 别名]
class JobModelTest(TestCase):

    def setUp(self):
        self.job = Job()
        self.job.audit = AuditFactory()
        self.job.user = UserFactory()

    def test_jobs_can_be_created(self):
        self.job.full_clean()  # Should not raise
        self.job.save()        # Should not raise

    def test_job_initial_state(self):
        "Job initial state should be RECEIVED"
        self.assertEqual(self.job.state, Job.RECEIVED_STATE)

    def test_job_creation_timestamp(self):
        start = timezone.now()
        job = JobFactory()
        end = timezone.now()

        self.assertLessEqual(start, job.created_at)
        self.assertLessEqual(job.created_at, end)

    def test_job_report_url(self):
        "Fresh and unfinished jobs have no report file"
        job = JobFactory()
        with self.assertRaises(ValueError):
            job.report_file.url


    @patch('django.core.files.storage.default_storage._wrapped')
    def test_finished_job_report_url(self, storage_mock):
        file_mock = MagicMock(spec=File, name='FileMock')
        file_mock.name = 'test_file.txt'

        storage_mock.url = MagicMock('url')
        storage_mock.url.return_value = file_mock.name
        storage_mock.save.return_value = file_mock

        self.job.add_report(file_mock)

        self.assertEqual(self.job.report_file, file_mock)
        self.assertEqual(self.job.state, Job.SUCCESS_STATE)
开发者ID:tilacog,项目名称:paranoid,代码行数:45,代码来源:test_models.py


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