# Path: zfs_autobackup/LogStub.py
# class LogStub:
#     """Just a stub, usually overriden in subclasses."""
# 
#     # simple logging stubs
#     def debug(self, txt):
#         print("DEBUG  : " + txt)
# 
#     def verbose(self, txt):
#         print("VERBOSE: " + txt)
# 
#     def warning(self, txt):
#         print("WARNING: " + txt)
# 
#     def error(self, txt):
#         print("ERROR  : " + txt)
# 
# Path: zfs_autobackup/ExecuteNode.py
# class ExecuteError(Exception):
#     pass


from basetest import *
from zfs_autobackup.LogStub import LogStub
from zfs_autobackup.ExecuteNode import ExecuteError
                print(buf.getvalue())
                self.assertIn("STDOUT > pre1", buf.getvalue())
                self.assertIn("STDOUT > pre2", buf.getvalue())
                self.assertIn("STDOUT > post1", buf.getvalue())
                self.assertIn("STDOUT > post2", buf.getvalue())


    def test_getselected(self):

        # should be excluded by property
        shelltest("zfs create test_source1/fs1/subexcluded")
        shelltest("zfs set autobackup:test=false test_source1/fs1/subexcluded")

        # should be excluded by being unchanged
        shelltest("zfs create test_source1/fs1/unchanged")
        shelltest("zfs snapshot test_source1/fs1/unchanged@somesnapshot")

        logger = LogStub()
        description = "[Source]"
        node = ZfsNode(snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
        s = pformat(node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=True, min_change=1))
        print(s)

        # basics
        self.assertEqual(s, """[(local): test_source1/fs1,
 (local): test_source1/fs1/sub,
 (local): test_source2/fs2/sub]""")


    def test_validcommand(self):

# Path: zfs_autobackup/LogStub.py
# class LogStub:
#     """Just a stub, usually overriden in subclasses."""
# 
#     # simple logging stubs
#     def debug(self, txt):
#         print("DEBUG  : " + txt)
# 
#     def verbose(self, txt):
#         print("VERBOSE: " + txt)
# 
#     def warning(self, txt):
#         print("WARNING: " + txt)
# 
#     def error(self, txt):
#         print("ERROR  : " + txt)
# 
# Path: zfs_autobackup/ExecuteNode.py
# class ExecuteError(Exception):
#     pass


# Path: tests/test_zfsnode.py
from basetest import *
from zfs_autobackup.LogStub import LogStub
from zfs_autobackup.ExecuteNode import ExecuteError

                print(buf.getvalue())
                self.assertIn("STDOUT > pre1", buf.getvalue())
                self.assertIn("STDOUT > pre2", buf.getvalue())
                self.assertIn("STDOUT > post1", buf.getvalue())
                self.assertIn("STDOUT > post2", buf.getvalue())


    def test_getselected(self):

        # should be excluded by property
        shelltest("zfs create test_source1/fs1/subexcluded")
        shelltest("zfs set autobackup:test=false test_source1/fs1/subexcluded")

        # should be excluded by being unchanged
        shelltest("zfs create test_source1/fs1/unchanged")
        shelltest("zfs snapshot test_source1/fs1/unchanged@somesnapshot")

        logger = LogStub()
        description = "[Source]"
        node = ZfsNode(snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
        s = pformat(node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=True, min_change=1))
        print(s)

        # basics
        self.assertEqual(s, """[(local): test_source1/fs1,
 (local): test_source1/fs1/sub,
 (local): test_source2/fs2/sub]""")


    def test_validcommand(self):

        logger = LogStub()