Ejemplo n.º 1
0
 def test_cannot_unlock_with_non_matching_keycard4(self):
     k1 = Key()
     k2 = Key()
     k3 = Key()
     lock = Lock(k1, k2)
     keycard = KeyCard(k3, k1)
     assert not lock.can_be_unlocked(keycard)
Ejemplo n.º 2
0
 def test_can_unlock_with_partially_matching_keycard(self):
     k1 = Key()
     k2 = Key()
     k3 = Key()
     lock = Lock(k1, k2)
     keycard1 = KeyCard(k2, k3)
     # can unlock with partial match
     assert lock.can_be_unlocked(keycard1)
     keycard2 = KeyCard(k2, k1)
     # cannot unlock with partial match
     assert not lock.can_be_unlocked(keycard2)
Ejemplo n.º 3
0
 def test_cannot_unlock_with_invalid_keycard_type(self, value):
     key = Key()
     lock = Lock(key, key)
     with pytest.raises(ValueError):
         lock.can_be_unlocked(value)
Ejemplo n.º 4
0
 def test_can_create_lock_with_same_valid_keys(self):
     tmp1 = Key()
     Lock(tmp1, tmp1)
Ejemplo n.º 5
0
 def test_can_create_lock_with_distinct_valid_keys(self):
     Lock(Key(), Key())
Ejemplo n.º 6
0
 def test_cannot_create_lock_with_invalid_key_types(self, k1, k2):
     with pytest.raises(ValueError):
         Lock(k1, k2)
Ejemplo n.º 7
0
 def test_cannot_create_lock_with_invalid_second_key_type(self, k2):
     with pytest.raises(ValueError):
         Lock(Key(), k2)
Ejemplo n.º 8
0
 def test_cannot_create_lock_with_invalid_first_key_type(self, k1):
     with pytest.raises(ValueError):
         Lock(k1, Key())
Ejemplo n.º 9
0
 def test_lock_returns_initialized_lock(self, num):
     lock = Lock(Key(), Key())
     assert Room(num, lock).lock == lock
Ejemplo n.º 10
0
 def test_room_number_returns_initialized_room_number(self, num):
     assert Room(num, Lock(Key(), Key())).room_number == num
Ejemplo n.º 11
0
 def test_can_create_room_with_valid_room_number_and_lock(self, num):
     Room(num, Lock(Key(), Key()))
Ejemplo n.º 12
0
 def test_cannot_create_room_with_invalid_room_number(self, num):
     with pytest.raises(ValueError):
         Room(num, Lock(Key(), Key()))
Ejemplo n.º 13
0
 def test_can_unlock_with_matching_keycard(self):
     k1 = Key()
     k2 = Key()
     keycard = KeyCard(k1, k2)
     lock = Lock(k1, k2)
     assert lock.can_be_unlocked(keycard)