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)
 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)
 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)
 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)