class TestIsoReader(unittest.TestCase):
    def setUp(self):
        with open('tests/test_data/iso-19115_mi.xml', 'r') as f:
            text = f.read()
        text = text.replace('\\n', ' ')
        self.reader = IsoReader(text)
        self.reader._load_xml()

    def test_return_descriptors(self):
        descriptors = self.reader.return_service_descriptors()

        self.assertTrue('Survey, Massachusetts Bay, Massachusetts,' in descriptors['title'][0])
        self.assertTrue('version' not in descriptors)
        self.assertTrue('Massachusetts Bay' in descriptors['subject'])
        self.assertTrue(len(descriptors['subject']) == 15)
        self.assertTrue(descriptors['language'][0] == 'eng')

    def test_parse_endpoints(self):
        endpoints = self.reader.parse_endpoints()

        expected_url = 'http://surveys.ngdc.noaa.gov/mgg/NOS/coast/' + \
                       'H08001-H10000/H08413/Smooth_Sheets/H08413.tif.gz'
        expected_format = 'SMOOTH_SHEET'

        self.assertTrue(len(endpoints) == 4)
        self.assertTrue(endpoints[2]['type'] == 'download')
        self.assertTrue(endpoints[1]['url'] == expected_url)
        self.assertTrue(endpoints[1]['format'] == expected_format)
class TestIsoReader(unittest.TestCase):
    def setUp(self):
        with open("tests/test_data/iso-19115_mi.xml", "r") as f:
            text = f.read()
        text = text.replace("\\n", " ")
        self.reader = IsoReader(text)
        self.reader._load_xml()

    def test_return_descriptors(self):
        descriptors = self.reader.return_service_descriptors()

        self.assertTrue("Survey, Massachusetts Bay, Massachusetts," in descriptors["title"][0])
        self.assertTrue("version" not in descriptors)
        self.assertTrue("Massachusetts Bay" in descriptors["subject"])
        self.assertTrue(len(descriptors["subject"]) == 15)
        self.assertTrue(descriptors["language"][0] == "eng")

    def test_parse_endpoints(self):
        endpoints = self.reader.parse_endpoints()

        expected_url = (
            "http://surveys.ngdc.noaa.gov/mgg/NOS/coast/" + "H08001-H10000/H08413/Smooth_Sheets/H08413.tif.gz"
        )
        expected_format = "SMOOTH_SHEET"

        self.assertTrue(len(endpoints) == 4)
        self.assertTrue(endpoints[2]["type"] == "download")
        self.assertTrue(endpoints[1]["url"] == expected_url)
        self.assertTrue(endpoints[1]["format"] == expected_format)
 def setUp(self):
     with open('tests/test_data/iso-19115_mi.xml', 'r') as f:
         text = f.read()
     text = text.replace('\\n', ' ')
     self.reader = IsoReader(text)
     self.reader._load_xml()
 def setUp(self):
     with open("tests/test_data/iso-19115_mi.xml", "r") as f:
         text = f.read()
     text = text.replace("\\n", " ")
     self.reader = IsoReader(text)
     self.reader._load_xml()