def test_add_contact_info_agency(self): """Agency & Office should be added to `contact` dictionary if not present""" row = self.empty_row() row["Department"] = "ACRONYM" row["Agency"] = "Sewage Treatment" contact_dict = {} layer.add_contact_info(contact_dict, row) self.assertTrue("ACRONYM" in contact_dict) self.assertTrue("Sewage Treatment" in contact_dict["ACRONYM"]) # Adding again has no affect layer.add_contact_info(contact_dict, row) self.assertTrue("ACRONYM" in contact_dict) self.assertTrue("Sewage Treatment" in contact_dict["ACRONYM"]) # Adding another agency row["Agency"] = "Road Maintenance" layer.add_contact_info(contact_dict, row) self.assertTrue("ACRONYM" in contact_dict) self.assertTrue("Sewage Treatment" in contact_dict["ACRONYM"]) self.assertTrue("Road Maintenance" in contact_dict["ACRONYM"]) # Adding another agency with leading and trailing spaces row["Agency"] = " Economic Development " layer.add_contact_info(contact_dict, row) self.assertTrue("ACRONYM" in contact_dict) self.assertTrue("Sewage Treatment" in contact_dict["ACRONYM"]) self.assertTrue("Road Maintenance" in contact_dict["ACRONYM"]) self.assertTrue("Economic Development" in contact_dict["ACRONYM"])
def test_add_contact_info_people(self): """Verify that the title of a row indicates which field it should be placed in""" row = self.empty_row() row["Department"] = "A" row["Agency"] = "B" row["Name"] = "Ada" contact_dict = {} layer.add_contact_info(contact_dict, row) self.assertFalse("service_center" in contact_dict["A"]["B"]) self.assertEqual(contact_dict["A"]["B"]["misc"], {}) row["Title"] = "Awesome Person" layer.add_contact_info(contact_dict, row) self.assertFalse("service_center" in contact_dict["A"]["B"]) self.assertEqual(contact_dict["A"]["B"]["misc"], {'Awesome Person': { 'name': 'Ada' }}) row["Name"] = "Bob" row["Title"] = "FOIA Service Center Technician" layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["service_center"], {'name': 'Bob'}) self.assertEqual(contact_dict["A"]["B"]["misc"], {'Awesome Person': { 'name': 'Ada' }})
def test_add_contact_info_people(self): """Verify that the title of a row indicates which field it should be placed in""" row = self.empty_row() row["Department"] = "A" row["Agency"] = "B" row["Name"] = "Ada" contact_dict = {} layer.add_contact_info(contact_dict, row) self.assertFalse("service_center" in contact_dict["A"]["B"]) self.assertEqual(contact_dict["A"]["B"]["misc"], {}) row["Title"] = "Awesome Person" layer.add_contact_info(contact_dict, row) self.assertFalse("service_center" in contact_dict["A"]["B"]) self.assertEqual(contact_dict["A"]["B"]["misc"], {'Awesome Person': {'name': 'Ada'}}) row["Name"] = "Bob" row["Title"] = "FOIA Service Center Technician" layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["service_center"], {'name': 'Bob'}) self.assertEqual(contact_dict["A"]["B"]["misc"], {'Awesome Person': {'name': 'Ada'}})
def test_add_contact_info_emails(self): """Each row that contains an email address should get added to the list""" row = self.empty_row() row["Department"] = "A" row["Agency"] = "B" contact_dict = {} layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["emails"], []) row["Email Address"] = "*****@*****.**" layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["emails"], ["*****@*****.**"]) row["Email Address"] = "*****@*****.**" layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["emails"], ["*****@*****.**", "*****@*****.**"]) # Check that no duplicate emails are added row["Email Address"] = "*****@*****.**" layer.add_contact_info(contact_dict, row) self.assertEqual(contact_dict["A"]["B"]["emails"], ["*****@*****.**", "*****@*****.**"])
def test_add_contact_info_website(self): """Website field gets cleaned up -- verify it's not added unless it's in the right form""" row = self.empty_row() row["Department"] = "A" row["Agency"] = "B" contact_dict = {} layer.add_contact_info(contact_dict, row) self.assertFalse("website" in contact_dict["A"]["B"]) row["Website"] = "http://" layer.add_contact_info(contact_dict, row) self.assertFalse("website" in contact_dict["A"]["B"]) row["Website"] = "http://example.gov" layer.add_contact_info(contact_dict, row) self.assertEqual("http://example.gov", contact_dict["A"]["B"]["website"])