def test_value_init(self): """Test default Row object creation""" # 1. Create default claim object myrow = row.Row(number=4) # 2. Make sure it has the default values self.assertEqual(myrow.number, 4) self.assertEqual(len(myrow.counts), 0) # 3. Check methods claim1 = claim.Claim(text='#1 @ 1,3: 4x4') myrow.add_claim(claim1) self.assertEqual(len(myrow.counts), 4) self.assertEqual(myrow.claimed(), 4) self.assertEqual(myrow.overlap(), 0) claim2 = claim.Claim(text='#2 @ 3,1: 4x4') myrow.add_claim(claim2) self.assertEqual(len(myrow.counts), 6) self.assertEqual(myrow.claimed(), 6) self.assertEqual(myrow.overlap(), 2) claim3 = claim.Claim(text='#3 @ 5,5: 2x2') myrow.add_claim(claim3) self.assertEqual(len(myrow.counts), 6) self.assertEqual(myrow.claimed(), 6) self.assertEqual(myrow.overlap(), 2)
def test_does_overlap(self): """Test Claim overlap detection""" # 1. Create some claim objects claim1 = claim.Claim(text='#1 @ 1,3: 4x4') claim2 = claim.Claim(text='#2 @ 3,1: 4x4') claim3 = claim.Claim(text='#3 @ 5,5: 2x2') # 2. Check for overlaps self.assertEqual(claim1.does_overlap(claim1), True) self.assertEqual(claim1.does_overlap(claim2), True) self.assertEqual(claim1.does_overlap(claim3), False) self.assertEqual(claim2.does_overlap(claim1), True) self.assertEqual(claim2.does_overlap(claim2), True) self.assertEqual(claim2.does_overlap(claim3), False) self.assertEqual(claim3.does_overlap(claim1), False) self.assertEqual(claim3.does_overlap(claim2), False) self.assertEqual(claim3.does_overlap(claim3), True)
def test_text_init(self): """Test Claim object creation with text""" # 1. Create default claim object myclaim = claim.Claim(text='#1 @ 1,3: 4x4') # 2. Make sure it has the default values self.assertEqual(myclaim.number, 1) self.assertEqual(myclaim.left, 1) self.assertEqual(myclaim.top, 3) self.assertEqual(myclaim.width, 4) self.assertEqual(myclaim.height, 4) self.assertEqual(myclaim.right, 4) self.assertEqual(myclaim.bottom, 6) # 3. Check methods self.assertEqual(str(myclaim), '#1 @ 1,3: 4x4')
def test_values_init(self): """Test Claim object creation with values""" # 1. Create default claim object myclaim = claim.Claim(number=2, left=3, top=1, width=4, height=4) # 2. Make sure it has the default values self.assertEqual(myclaim.number, 2) self.assertEqual(myclaim.left, 3) self.assertEqual(myclaim.top, 1) self.assertEqual(myclaim.width, 4) self.assertEqual(myclaim.height, 4) self.assertEqual(myclaim.right, 6) self.assertEqual(myclaim.bottom, 4) # 3. Check methods self.assertEqual(str(myclaim), '#2 @ 3,1: 4x4')
def test_empty_init(self): """Test default Claim object creation""" # 1. Create default claim object myclaim = claim.Claim() # 2. Make sure it has the default values self.assertEqual(myclaim.number, 0) self.assertEqual(myclaim.left, 0) self.assertEqual(myclaim.top, 0) self.assertEqual(myclaim.width, 1) self.assertEqual(myclaim.height, 1) self.assertEqual(myclaim.right, 0) self.assertEqual(myclaim.bottom, 0) # 3. Check methods self.assertEqual(str(myclaim), '#0 @ 0,0: 1x1')
def register_claims(input_lines): "Return the number of characters that appear twice and three times" # 1. Start with no claims claims = [] # 2. Loop through all of the claims for line in input_lines: # 3. Create claim from text one_claim = claim.Claim(text=line) # 4. Add the new claim to the list claims.append(one_claim) # 5. Return the all the claims return claims
def create_claim(claimID, claimtype, description, claimamount, dateofincident, dateofclaim, isvalid): new_claim = claim.Claim(claimID, claimtype, description, claimamount, dateofincident, dateofclaim, isvalid) all_claims.append(new_claim)
def Add_A_Claim(ClaimID, ClaimType, Description, ClaimAmount, DateOfIncident, DateOfClaim, IsValid): C = claim.Claim(ClaimID, ClaimType, Description, ClaimAmount, DateOfIncident, DateOfClaim, IsValid) number_of_claims.append(C)