Beispiel #1
0
 def test_engageResource_that_is_free(self):
     want = {'a': 'user'}
     r = resource_manager.ResourceManager('a')
     r.engageResource('a', 'user')
     got = r._resources
     assert got == want
Beispiel #2
0
 def test_engageResource_that_is_not_in_list(self):
     r = resource_manager.ResourceManager()
     with pytest.raises(KeyError):
         r.engageResource('a', 'user')
Beispiel #3
0
 def test_engageResource_that_is_engaged(self):
     r = resource_manager.ResourceManager('a')
     r.engageResource('a', 'first user')
     with pytest.raises(resource_manager.Engaged):
         r.engageResource('a', 'user')
Beispiel #4
0
 def test_init_without_list(self):
     want = {}
     r = resource_manager.ResourceManager()
     got = r._resources
     assert got == want
Beispiel #5
0
 def test_removeResource_from_non_empty_list(self):
     want = {}
     r = resource_manager.ResourceManager('a')
     r.removeResource('a')
     got = r._resources
     assert got == want
Beispiel #6
0
 def test_removeResource_from_empty_list(self):
     r = resource_manager.ResourceManager()
     with pytest.raises(KeyError):
         r.removeResource('a')
Beispiel #7
0
 def test_addResource_with_int(self):
     r = resource_manager.ResourceManager()
     with pytest.raises(TypeError):
         r.addResource(5)
Beispiel #8
0
 def test_addResource_with_string_to_non_empty_list(self):
     want = {'a': None, 'b': None}
     r = resource_manager.ResourceManager('a')
     r.addResource('b')
     got = r._resources
     assert got == want
Beispiel #9
0
 def test_init_with_list(self):
     want = {'a': None, 'b': None}
     r = resource_manager.ResourceManager(['a', 'b'])
     got = r._resources
     assert got == want
Beispiel #10
0
 def test_init_with_None(self):
     want = {}
     r = resource_manager.ResourceManager(None)
     got = r._resources
     assert got == want