예제 #1
0
 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"])
예제 #2
0
 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"])
예제 #3
0
    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'
                         }})
예제 #4
0
    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'}})
예제 #5
0
    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"],
                         ["*****@*****.**", "*****@*****.**"])
예제 #6
0
    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"],
                         ["*****@*****.**", "*****@*****.**"])
예제 #7
0
    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"])
예제 #8
0
    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"])