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_can_create_keycard_with_same_valid_keys(self):
     tmp1 = Key()
     KeyCard(tmp1, tmp1)
 def test_can_create_keycard_with_distinct_valid_keys(self):
     KeyCard(Key(), Key())
 def test_cannot_create_keycard_with_invalid_key_types(self, k1, k2):
     with pytest.raises(ValueError):
         KeyCard(k1, k2)
 def test_cannot_create_keycard_with_invalid_second_key_type(self, k2):
     with pytest.raises(ValueError):
         KeyCard(Key(), k2)
 def test_cannot_create_keycard_with_invalid_first_key_type(self, k1):
     with pytest.raises(ValueError):
         KeyCard(k1, Key())
 def test_is_checkedin_fails_with_invalid_hotel_type(self, name, num,
                                                     value):
     kc = KeyCard(Key(), Key())
     g = Guest(name, num, kc)
     with pytest.raises(ValueError):
         g.is_checkedin(value)
 def test_room_number_returns_initialized_room_number(self, name, num):
     assert Guest(name, num, KeyCard(Key(), Key())).room_number == num
예제 #10
0
 def test_guest_name_returns_initialized_name(self, name, num):
     assert Guest(name, num, KeyCard(Key(), Key())).guest_name == name
예제 #11
0
 def test_can_create_guest_with_valid_arguments(self, name, num):
     Guest(name, num, KeyCard(Key(), Key()))
예제 #12
0
 def test_cannot_create_guest_with_invalid_name2(self, name, num):
     assume(re.sub(r'[a-zA-Z ]', '', name))
     with pytest.raises(ValueError):
         Guest(name, num, KeyCard(Key(), Key()))
예제 #13
0
 def test_cannot_create_guest_with_invalid_name1(self, name, num):
     with pytest.raises(ValueError):
         Guest(name, num, KeyCard(Key(), Key()))
예제 #14
0
 def test_cannot_create_guest_with_invalid_room_number(self, num):
     with pytest.raises(ValueError):
         Guest("John", num, KeyCard(Key(), Key()))
예제 #15
0
 def test_first_key_returns_first_key(self):
     k1 = Key()
     k2 = Key()
     kc = KeyCard(k1, k2)
     assert kc.first_key == k1
예제 #16
0
 def test_keycard_returns_initialized_keycard(self, name, num):
     kc = KeyCard(Key(), Key())
     assert Guest(name, num, kc).keycard == kc
예제 #17
0
 def test_second_key_returns_second_key(self):
     k1 = Key()
     k2 = Key()
     kc = KeyCard(k1, k2)
     assert kc.second_key == k2
예제 #18
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)