本文整理匯總了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)