def test_destination_directory_levels_deep(self):
        from pecan.scaffolds import copy_dir
        f = StringIO()
        copy_dir(
            (
                'pecan', os.path.join('tests', 'scaffold_fixtures', 'simple')
            ),
            os.path.join(self.scaffold_destination, 'some', 'app'),
            {},
            out_=f
        )

        assert os.path.isfile(os.path.join(
            self.scaffold_destination, 'some', 'app', 'foo')
        )
        assert os.path.isfile(os.path.join(
            self.scaffold_destination, 'some', 'app', 'bar', 'spam.txt')
        )
        with open(os.path.join(
            self.scaffold_destination, 'some', 'app', 'foo'
        ), 'r') as f:
            assert f.read().strip() == 'YAR'
        with open(os.path.join(
            self.scaffold_destination, 'some', 'app', 'bar', 'spam.txt'
        ), 'r') as f:
            assert f.read().strip() == 'Pecan'
    def test_copy_dir_with_file_content_substitution(self):
        from pecan.scaffolds import copy_dir
        copy_dir(
            (
                'pecan',
                os.path.join('tests', 'scaffold_fixtures', 'content_sub'),
            ),
            os.path.join(
                self.scaffold_destination, 'someapp'
            ),
            {'package': 'thingy'},
            out_=StringIO()
        )

        assert os.path.isfile(os.path.join(
            self.scaffold_destination, 'someapp', 'foo')
        )
        assert os.path.isfile(os.path.join(
            self.scaffold_destination, 'someapp', 'bar', 'spam.txt')
        )
        with open(os.path.join(
            self.scaffold_destination, 'someapp', 'foo'
        ), 'r') as f:
            assert f.read().strip() == 'YAR thingy'
        with open(os.path.join(
            self.scaffold_destination, 'someapp', 'bar', 'spam.txt'
        ), 'r') as f:
            assert f.read().strip() == 'Pecan thingy'
 def test_destination_directory_already_exists(self):
     from pecan.scaffolds import copy_dir
     f = StringIO()
     copy_dir(
         ('pecan', os.path.join('tests', 'scaffold_fixtures', 'simple')),
         os.path.join(self.scaffold_destination), {},
         out_=f)
     assert 'already exists' in f.getvalue()
Esempio n. 4
0
 def test_destination_directory_already_exists(self):
     from pecan.scaffolds import copy_dir
     f = StringIO()
     copy_dir(
         (
             'pecan', os.path.join('tests', 'scaffold_fixtures', 'simple')
         ),
         os.path.join(self.scaffold_destination),
         {},
         out_=f
     )
     assert 'already exists' in f.getvalue()
Esempio n. 5
0
    def test_destination_directory_already_exists(self):
        from pecan.scaffolds import copy_dir
        from cStringIO import StringIO

        f = StringIO()
        copy_dir(
            ("pecan", os.path.join("tests", "scaffold_fixtures", "simple")),
            os.path.join(self.scaffold_destination),
            {},
            out_=f,
        )
        assert "already exists" in f.getvalue()
Esempio n. 6
0
    def test_copy_dir_with_filename_substitution(self):
        from pecan.scaffolds import copy_dir

        copy_dir(
            ("pecan", os.path.join("tests", "scaffold_fixtures", "file_sub")),
            os.path.join(self.scaffold_destination, "someapp"),
            {"package": "thingy"},
            out_=StringIO(),
        )

        assert os.path.isfile(os.path.join(self.scaffold_destination, "someapp", "foo_thingy"))
        assert os.path.isfile(os.path.join(self.scaffold_destination, "someapp", "bar_thingy", "spam.txt"))
        assert open(os.path.join(self.scaffold_destination, "someapp", "foo_thingy"), "r").read().strip() == "YAR"
        assert (
            open(os.path.join(self.scaffold_destination, "someapp", "bar_thingy", "spam.txt"), "r").read().strip()
            == "Pecan"
        )
Esempio n. 7
0
    def test_destination_directory_levels_deep(self):
        from pecan.scaffolds import copy_dir

        f = StringIO()
        copy_dir(
            ("pecan", os.path.join("tests", "scaffold_fixtures", "simple")),
            os.path.join(self.scaffold_destination, "some", "app"),
            {},
            out_=f,
        )

        assert os.path.isfile(os.path.join(self.scaffold_destination, "some", "app", "foo"))
        assert os.path.isfile(os.path.join(self.scaffold_destination, "some", "app", "bar", "spam.txt"))
        assert open(os.path.join(self.scaffold_destination, "some", "app", "foo"), "r").read().strip() == "YAR"
        assert (
            open(os.path.join(self.scaffold_destination, "some", "app", "bar", "spam.txt"), "r").read().strip()
            == "Pecan"
        )