diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93c5ca2..8023908 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: run: | git clone -b master https://github.com/internetofwater/geoconnex.us.git geoconnex.us cd geoconnex.us - git checkout e0e1c2ba0d023bfd80f3e6d76c85c01fab35c581 + git checkout 4cc92f91abbecf20650ac595d81726062ffb3894 - uses: actions/setup-python@v2 name: Setup Python ${{ matrix.python-version }} with: diff --git a/sitemap_generator/util.py b/sitemap_generator/util.py index b6354a0..6d80e5a 100644 --- a/sitemap_generator/util.py +++ b/sitemap_generator/util.py @@ -62,7 +62,12 @@ def write_tree(tree, file): + ET.register_namespace('', 'http://www.sitemaps.org/schemas/sitemap/0.9') tree.write(file, **SITEMAP_ARGS) + try: + ET._namespace_map.pop('http://www.sitemaps.org/schemas/sitemap/0.9') + except KeyError: + print('No default namespace') def get_smi(): diff --git a/tests/data/namespaces/iow/autotest1.csv b/tests/data/namespaces/iow/autotest1.csv deleted file mode 100644 index 09952f7..0000000 --- a/tests/data/namespaces/iow/autotest1.csv +++ /dev/null @@ -1,3 +0,0 @@ -id, target, creator, description -https://geoconnex.us/iow/homepage, https://internetofwater.org, kyle.onda@gmail.com, Testing the auto-update github action -https://geoconnex.us/demo, https://geoconnex.internetofwater.dev/demo, kyle.onda@duke.edu, Testing CI/CD diff --git a/tests/data/namespaces/iow/links__0.xml b/tests/data/namespaces/iow/links__0.xml index 03941d9..e6fea45 100644 --- a/tests/data/namespaces/iow/links__0.xml +++ b/tests/data/namespaces/iow/links__0.xml @@ -1,24 +1,40 @@ + - + + https://geoconnex.us/iow/homepage + 2023-09-01T05:34:10Z + + https://geoconnex.us/iow/aboutus + 2023-09-01T05:34:10Z + + https://geoconnex.us/demo + 2023-09-01T05:34:10Z + https://geoconnex.us/iow/nldi - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/nldi/demo - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/map - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/cr-demo - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/tracker - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/hyriver - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z https://geoconnex.us/iow/principles - 2023-06-23T22:38:13Z + 2023-09-01T05:34:10Z + + https://geoconnex.us/iow/api-mockups + 2023-09-01T05:34:10Z + + https://geoconnex.us/iow/guidance + 2023-09-01T05:34:10Z \ No newline at end of file diff --git a/tests/test_handler.py b/tests/test_handler.py index 7035295..a3c7c94 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -62,11 +62,10 @@ def test_sitemapindex(): tree = ET.parse(sitemapindex) root = tree.getroot() - assert all(child.tag == 'sitemap' for child in root) - assert all(URI_STEM in child.find('loc').text for child in root) - - links = root.find('sitemap') - assert links.find('lastmod').text != today + assert all('sitemap' in child.tag for child in root) + for child in root: + assert URI_STEM in ''.join(child.itertext()) + assert all(URI_STEM in ''.join(child.itertext()) for child in root) def test_urlset(): @@ -81,15 +80,3 @@ def test_urlset(): namespace = url_join(URI_STEM, HANDLER.get_rel_path(urlset)) assert namespace == 'https://geoconnex.us/iow' - - [urlset] = list(walk_path(SITEMAP_DIR, r'.*autotest1__0.xml')) - file_time = HANDLER.get_filetime(urlset) - tree = ET.parse(urlset) - root = tree.getroot() - - assert all(child.tag == 'url' for child in root) - assert all(file_time == child.find('lastmod').text for child in root) - - url = root.find('url') - lastmod = url.find('lastmod').text - assert lastmod == '2021-11-17T16:24:48Z' diff --git a/tests/test_util.py b/tests/test_util.py index c39afc3..84c9b8c 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -37,7 +37,7 @@ def test_walk_path(): glob_all = list(util.walk_path(NAMESPACE, r'.*')) - assert len(glob_all) >= 3 + assert len(glob_all) >= 2 glob = util.walk_path(NAMESPACE, r'.*csv') assert len(list(glob)) < len(glob_all)