本文整理汇总了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)