def test_allocate_when_unavailable_must_raise(self):
        m = {"n": 0}
        s = Storage(0, "0", True, m)
        s._set_unavailable()
        with pytest.raises(RuntimeError) as excinfo:
            s._allocate("job")

        assert "unavailable" in str(excinfo.value)
 def test_release_when_multiple_jobs_are_allocated(self):
     s = Storage(0, "n")
     s._allocate("j1")
     s._allocate("j2")
     s._release("j1")
     assert s.jobs and len(s.jobs) == 1 and s.jobs[0] == "j2"
 def test_release_valid(self):
     s = Storage(0, "n")
     s._allocate("job")
     s._release("job")
     assert not s.jobs
 def test_allocate_job_twice_must_not_raise(self):
     s = Storage(0, "n")
     s._allocate("j1")
     s._allocate("j1")
     assert s.jobs and len(s.jobs) == 1
 def test_allocate_multiple_jobs_when_not_shareable_must_raise(self):
     s = Storage(0, "n", False)
     s._allocate("j1")
     with pytest.raises(RuntimeError) as excinfo:
         s._allocate("j2")
     assert "multiple jobs" in str(excinfo.value)
 def test_allocate_multiple_jobs_valid(self):
     s = Storage(0, "n")
     s._allocate("j1")
     s._allocate("j2")
     assert "j1" in s.jobs
     assert "j2" in s.jobs
 def test_allocate_valid(self):
     s = Storage(0, "n")
     s._allocate("job")
     assert s.jobs and s.jobs[0] == "job"
 def test_set_unavailable_when_already_allocated_must_not_raise(self):
     m = {"n": 0}
     s = Storage(0, "0", True, m)
     s._allocate("job")
     s._set_unavailable()
     assert s.is_unavailable and s.jobs