Ejemplo n.º 1
0
    def test_it(self):
        import os.path
        from korpokkur.testing import temporary_environment
        from korpokkur.compat import text_

        with temporary_environment() as root:
            input_data = {"foo": {"setup.py": ":setup.py:", "readme.txt": u"日本語", "sample": {"foo.txt": "foo"}}}
            self._callFUT(root, input_data)

            is_exists = lambda x: os.path.join(root, x)

            ## file structure
            self.assertTrue(is_exists("foo"))
            self.assertTrue(is_exists("foo/setup.py"))
            self.assertTrue(is_exists("foo/readme.txt"))
            self.assertTrue(is_exists("foo/sample"))
            self.assertTrue(is_exists("foo/sample/foo.txt"))

            def read_data(x):
                with open(os.path.join(root, x)) as rf:
                    return text_(rf.read())

            ## file content
            self.assertEqual(read_data("foo/setup.py"), ":setup.py:")
            self.assertEqual(read_data("foo/readme.txt"), u"日本語")
            self.assertEqual(read_data("foo/sample/foo.txt"), u"foo")
Ejemplo n.º 2
0
    def test_conflict__overwrite_is_false__then_exception_is_raised(self):
        from korpokkur import testing
        from korpokkur import FileConflict
        with testing.temporary_environment() as src_dir:
            dst_dir = "/my"

            structure_data = {
                "+package+": {
                    "setup.py.tmpl": "${package}",
                    "sample.txt": "yay"
                }
            }
            testing.file_structure_from_dict(src_dir, structure_data)

            from korpokkur.input import DictInput
            input = DictInput(testing.DummyScaffold(), {"package": "foo"})
            reproduction = testing.DummyReproduction(src_dir)

            with self.assertRaises(FileConflict):
                target = self._makeOne(input, reproduction)
                target.walk(os.path.join(src_dir, "+package+"),
                            dst_dir,
                            overwrite=False)
                target = self._makeOne(input, reproduction)
                target.walk(os.path.join(src_dir, "+package+"),
                            dst_dir,
                            overwrite=False)
Ejemplo n.º 3
0
    def test_it(self):
        from korpokkur import testing
        with testing.temporary_environment() as src_dir:
            dst_dir = "/my"

            structure_data = {
                "+package+": {
                    "setup.py.tmpl": "${package}",
                    "sample.txt": "yay"
                }
            }
            testing.file_structure_from_dict(src_dir, structure_data)

            from korpokkur.input import DictInput
            input = DictInput(testing.DummyScaffold(), {"package": "foo"})
            reproduction = testing.DummyReproduction(src_dir)
            target = self._makeOne(input, reproduction)
            target.walk(os.path.join(src_dir, "+package+"), dst_dir)

            self.assertEqual(len(reproduction.files), 1)
            self.assertEqual(len(reproduction.modified_files), 1)

            self.assertEqual(reproduction.files[0][0],
                             ":S:/+package+/sample.txt")
            self.assertEqual(reproduction.files[0][1], "/my/foo/sample.txt")

            self.assertEqual(reproduction.modified_files[0][0],
                             ":S:/+package+/setup.py.tmpl")
            self.assertEqual(reproduction.modified_files[0][1],
                             "/my/foo/setup.py")
Ejemplo n.º 4
0
    def test_it(self):
        import os.path
        from korpokkur.testing import temporary_environment
        from korpokkur.compat import text_

        with temporary_environment() as root:
            input_data = {
                "foo": {
                    "setup.py": ":setup.py:",
                    "readme.txt": u"日本語",
                    "sample": {
                        "foo.txt": "foo"
                    }
                }
            }
            self._callFUT(root, input_data)

            is_exists = lambda x: os.path.join(root, x)

            ## file structure
            self.assertTrue(is_exists("foo"))
            self.assertTrue(is_exists("foo/setup.py"))
            self.assertTrue(is_exists("foo/readme.txt"))
            self.assertTrue(is_exists("foo/sample"))
            self.assertTrue(is_exists("foo/sample/foo.txt"))

            def read_data(x):
                with open(os.path.join(root, x)) as rf:
                    return text_(rf.read())

            ## file content
            self.assertEqual(read_data("foo/setup.py"), ":setup.py:")
            self.assertEqual(read_data("foo/readme.txt"), u"日本語")
            self.assertEqual(read_data("foo/sample/foo.txt"), u"foo")
Ejemplo n.º 5
0
    def test_conflict__overwrite_is_true__ok(self):
        from korpokkur import testing
        with testing.temporary_environment() as src_dir:
            dst_dir = "/my"

            structure_data = {"+package+": {"setup.py.tmpl": "${package}", "sample.txt": "yay"}}
            testing.file_structure_from_dict(src_dir, structure_data)

            from korpokkur.input import DictInput
            input = DictInput(testing.DummyScaffold(), {"package": "foo"})
            reproduction = testing.DummyReproduction(src_dir)

            target = self._makeOne(input, reproduction)
            target.walk(os.path.join(src_dir, "+package+"), dst_dir, overwrite=True)
            target = self._makeOne(input, reproduction)
            target.walk(os.path.join(src_dir, "+package+"), dst_dir, overwrite=True)
Ejemplo n.º 6
0
    def test_it(self):
        from korpokkur import testing
        with testing.temporary_environment() as src_dir:
            dst_dir = "/my"

            structure_data = {"+package+": {"setup.py.tmpl": "${package}", "sample.txt": "yay"}}
            testing.file_structure_from_dict(src_dir, structure_data)

            from korpokkur.input import DictInput
            input = DictInput(testing.DummyScaffold(), {"package": "foo"})
            reproduction = testing.DummyReproduction(src_dir)
            target = self._makeOne(input, reproduction)
            target.walk(os.path.join(src_dir, "+package+"), dst_dir)

            self.assertEqual(len(reproduction.files), 1)
            self.assertEqual(len(reproduction.modified_files), 1)

            self.assertEqual(reproduction.files[0][0], ":S:/+package+/sample.txt")
            self.assertEqual(reproduction.files[0][1], "/my/foo/sample.txt")

            self.assertEqual(reproduction.modified_files[0][0], ":S:/+package+/setup.py.tmpl")
            self.assertEqual(reproduction.modified_files[0][1], "/my/foo/setup.py")
Ejemplo n.º 7
0
    def _callFUT(self, *args, **kwargs):
        from korpokkur.testing import temporary_environment

        return temporary_environment(*args, **kwargs)
Ejemplo n.º 8
0
 def _callFUT(self, *args, **kwargs):
     from korpokkur.testing import temporary_environment
     return temporary_environment(*args, **kwargs)