コード例 #1
0
 def test_insured(self):
     subject = User("snorlax")
     assert not subject.insured()
     result = subject.buy_insurance()
     assert result == "YA Broke @snorlax - it costs 1 Cool Point to buy insurance"
     assert not subject.insured()
     subject.update_cool_points(1)
     result = subject.buy_insurance()
     assert result == "@snorlax thank you for purchasing insurance"
     assert subject.insured()
コード例 #2
0
 def test_stealing_from_an_insured_person(self):
     random.seed(0)
     madonna = User("madonna")
     madonna.set_value("cool_points", 1)
     bowie = User("bowie")
     bowie.set_value("cool_points", 10)
     bowie.buy_insurance()
     assert bowie.insured()
     handbag = Command("handbag").save().allow_user("bowie")
     subject = Stealer(thief="madonna", target_sfx="handbag", victim="bowie")
     result = subject.steal()
     assert (
         result.metadata["stealing_result"]
         == f"@madonna was blocked by @bowie's insurance! Num Attempts: 0"
     )
     assert not bowie.insured()