def test_state_remains_consistent(self):
    random = np.random.RandomState(144135)
    subject = MockTask(state=task.JobState.UNSTARTED)
    for idx in range(50):
        change = random.randint(0, (4 if (idx > 30) else 3))
        if ((idx > 30) and (change == 3)):
            subject.mark_job_complete()
        elif (change == 2):
            subject.change_job_id('external', random.randint(0, 1000))
        elif (change == 1):
            subject.mark_job_started('test', random.randint(0, 1000))
        else:
            subject.mark_job_failed()
        if (subject.is_unstarted or subject.is_finished):
            self.assertIsNone(subject.node_id)
            self.assertIsNone(subject.job_id)
        else:
            self.assertIsNotNone(subject.node_id)
            self.assertIsNotNone(subject.job_id)
def test_state_remains_consistent(self):
    random = np.random.RandomState(144135)
    subject = MockTask(state=task.JobState.UNSTARTED)
    for idx in range(50):
        change = random.randint(0, (4 if (idx > 30) else 3))
        if ((idx > 30) and (change == 3)):
            subject.mark_job_complete()
        elif (change == 2):
            subject.change_job_id('external', random.randint(0, 1000))
        elif (change == 1):
            subject.mark_job_started('test', random.randint(0, 1000))
        else:
            subject.mark_job_failed()
        if (subject.is_unstarted or subject.is_finished):
            self.assertIsNone(subject.node_id)
            self.assertIsNone(subject.job_id)
        else:
            self.assertIsNotNone(subject.node_id)
            self.assertIsNotNone(subject.job_id)