def test_sorn_get_system_name(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_system_name() self.assertEqual(sorn.system_name, "Contracted Travel Services Program.")
def test_sorn_get_routine_uses(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_routine_uses() self.assertEqual(sorn.routine_uses, "a. A record of any case in which ...")
def test_get_sorn_text_after_a_given_heading(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_sorn_text_after_a_given_heading("SYSTEM NAME:", "system_name") self.assertEqual(sorn.system_name, "Contracted Travel Services Program.")
def test_sorn_get_pii(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_pii() self.assertEqual( sorn.pii, "Social Security Number; employee identification number;")
def test_get_full_xml(self): with patch('requests.get') as mock_get: mock_get.return_value.text = self.MOCK_XML mock_get.return_value.status_code = 200 sorn = Sorn(self.SORN_HTML_URL) sorn.get_full_xml() self.assertEqual(sorn.full_xml, self.MOCK_XML)
def test_sorn_get_retention(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_retention() self.assertEqual( sorn.retention, "Records kept by a Federal agency are maintained ...")
def test_sorn_get_purpose(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_purpose() self.assertEqual( sorn.purpose, "To establish a comprehensive beginning-to-end travel services system containing information ..." )
def test_build_xml_url(self): expected_xml_url = "https://www.federalregister.gov/documents/full_text/xml/2009/06/03/E9-12951.xml" sorn = Sorn(self.SORN_HTML_URL) self.assertEqual(sorn.xml_url, expected_xml_url)
def test_sorn_write_to_csv(self): sorn = Sorn(self.SORN_HTML_URL) sorn.full_xml = self.MOCK_XML sorn.get_system_name() sorn.get_pii() sorn.get_purpose() sorn.get_retention() sorn.get_routine_uses() with patch("builtins.open") as mock_file: with patch('csv.writer') as mock_csv: sorn.write_to_csv() mock_file.assert_called_with('gsa_sorns.csv', 'a', newline='') full_csv_row = [ 'Contracted Travel Services Program.', 'https://www.federalregister.gov/documents/2009/06/03/E9-12951/privacy-act-of-1974-notice-of-updated-systems-of-records', 'Social Security Number; employee identification number;', 'To establish a comprehensive beginning-to-end travel services system containing information ...', 'Records kept by a Federal agency are maintained ...', 'a. A record of any case in which ...' ] mock_csv.return_value.writerow.assert_called_once_with( full_csv_row)