
import os
import os.path

import pytest

from nikola import __main__

from ..base 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'))

    pages = os.path.join(target_dir, 'pages')
    assert os.path.isdir(pages)


@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():
    """Path to the Wordpress export file."""
    test_directory = os.path.dirname(__file__)
    return os.path.join(test_directory, '..', 'wordpress_export_example.xml')


import os.path
from glob import glob

import pytest

from nikola import __main__

from ..base 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)
    assert glob(os.path.join(folder, '*'))


@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():
    """Path to the Wordpress export file."""
    test_directory = os.path.dirname(__file__)
    return os.path.join(test_directory, '..', 'wordpress_export_example.xml')

Test that pages and posts are filled.
Test that pages and posts are filled.

  
- import os
  import os.path
+ from glob import glob
  
  import pytest
  
  from nikola import __main__
  
  from ..base 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):
-     pages = os.path.join(target_dir, 'pages')
+     folder = os.path.join(target_dir, dirname)
-     assert os.path.isdir(pages)
+     assert os.path.isdir(folder)
+     assert glob(os.path.join(folder, '*'))
  
  
  @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():
      """Path to the Wordpress export file."""
      test_directory = os.path.dirname(__file__)
      return os.path.join(test_directory, '..', 'wordpress_export_example.xml')
  
Test that pages and posts are filled.
## Code Before:

import os
import os.path

import pytest

from nikola import __main__

from ..base 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'))

    pages = os.path.join(target_dir, 'pages')
    assert os.path.isdir(pages)


@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():
    """Path to the Wordpress export file."""
    test_directory = os.path.dirname(__file__)
    return os.path.join(test_directory, '..', 'wordpress_export_example.xml')

## Instruction:
Test that pages and posts are filled.
## Code After:

import os.path
from glob import glob

import pytest

from nikola import __main__

from ..base 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)
    assert glob(os.path.join(folder, '*'))


@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():
    """Path to the Wordpress export file."""
    test_directory = os.path.dirname(__file__)
    return os.path.join(test_directory, '..', 'wordpress_export_example.xml')
