diff options
| author | 2021-02-03 19:17:00 -0500 | |
|---|---|---|
| committer | 2021-02-03 19:17:00 -0500 | |
| commit | 3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (patch) | |
| tree | a7cf56282e54f05785243bc1e903d6594f2c06ba /tests/integration/test_wordpress_import.py | |
| parent | 787b97a4cb24330b36f11297c6d3a7a473a907d0 (diff) | |
New upstream version 8.1.2.upstream/8.1.2
Diffstat (limited to 'tests/integration/test_wordpress_import.py')
| -rw-r--r-- | tests/integration/test_wordpress_import.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/integration/test_wordpress_import.py b/tests/integration/test_wordpress_import.py new file mode 100644 index 0000000..6d3bfb8 --- /dev/null +++ b/tests/integration/test_wordpress_import.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +""" +Testing the wordpress import. + +It will do create a new site with the import_wordpress command +and use that newly created site to make a build. +""" + +import os.path +from glob import glob + +import pytest + +from nikola import __main__ + +from .helper import cd +from .test_empty_build import ( # NOQA + test_archive_exists, + test_avoid_double_slash_in_rss, + test_check_files, +) + + +def test_import_created_files(build, target_dir): + assert os.path.exists(target_dir) + assert os.path.exists(os.path.join(target_dir, "conf.py")) + + +@pytest.mark.parametrize("dirname", ["pages", "posts"]) +def test_filled_directories(build, target_dir, dirname): + folder = os.path.join(target_dir, dirname) + assert os.path.isdir(folder) + content = glob(os.path.join(folder, "**"), recursive=True) + assert any(os.path.isfile(element) for element in content) + + +@pytest.fixture(scope="module") +def build(target_dir, import_file): + __main__.main( + [ + "import_wordpress", + "--no-downloads", + "--output-folder", + target_dir, + import_file, + ] + ) + + with cd(target_dir): + result = __main__.main(["build"]) + assert not result + + +@pytest.fixture(scope="module") +def import_file(test_dir): + """Path to the Wordpress export file.""" + return os.path.join( + test_dir, "..", "data", "wordpress_import", "wordpress_export_example.xml" + ) |
