def test_update_state(self):
     a = Borg("Mark")
     c = ChildShare("Paul", color="red")
     self.assertIn("color", a.state)
     d = ChildNotShare("Andrew", age=5)
     a.name = "James"
     self.assertEqual(a.name, c.name)
     self.assertNotEqual(a.name, d.name)
Ejemplo n.º 2
0
 def test_update_state(self):
     a = Borg('Mark')
     c = ChildShare('Paul', color='red')
     self.assertIn('color', a.state)
     d = ChildNotShare('Andrew', age=5)
     a.name = 'James'
     self.assertEqual(a.name, c.name)
     self.assertNotEqual(a.name, d.name)
Ejemplo n.º 3
0
 def test_initial_borg_state_shall_be_init(self):
     b = Borg()
     self.assertEqual(b.state, 'Init')
Ejemplo n.º 4
0
 def setUpClass(self):
     self.b1 = Borg()
     self.b2 = Borg()
     self.ib1 = YourBorg()
 def test_borg_and_childnotshare_do_not_share_common_state(self):
     a = Borg("Mark")
     d = ChildNotShare("Andrew", age=5)
     self.assertNotEqual(a.state, d.state)
 def test_borg_and_childshare_share_common_state(self):
     a = Borg("Mark")
     c = ChildShare("Paul", color="red")
     self.assertEqual(a.state, c.state)
 def test_two_borgs_share_common_state(self):
     a = Borg("Mark")
     b = Borg("Luke")
     self.assertEqual(a.state, b.state)
 def test_two_borgs_have_different_identity(self):
     a = Borg("Mark")
     b = Borg("Luke")
     self.assertIsNot(a, b)
Ejemplo n.º 9
0
    def run(self):
        self.config = configparser.ConfigParser(
            interpolation=configparser.ExtendedInterpolation(),
            inline_comment_prefixes=('#', ','))
        self.config.read(configfile)

        log_count = self.config['Common'].getint('log-count', logcount)
        log_size = self.config['Common'].getint('log-size', logsize)
        log_level = self.config['Common'].get('log-level', loglevel)
        log_file = os.path.expanduser(self.config['Common'].get(
            'log-file', logfile))

        log_formatter = logging.Formatter(
            "%(asctime)s [%(levelname)-5.5s]  %(message)s",
            "%Y-%m-%d %H:%M:%S")

        log_file_handler = RotatingFileHandler(log_file,
                                               maxBytes=log_size,
                                               backupCount=log_count)
        log_file_handler.setFormatter(log_formatter)

        log_console_handler = logging.StreamHandler()
        log_console_handler.setFormatter(log_formatter)

        self.logger = logging.getLogger("borg")
        self.logger.addHandler(log_file_handler)
        self.logger.addHandler(log_console_handler)

        # parse and set log level
        level = logging.getLevelName(log_level.upper())
        if isinstance(level, int):
            self.logger.setLevel(level)
        else:
            self.logger.setLevel(logging.INFO)

        Notify.init("BorgBackup")

        self.notifications = []
        self.log = {}

        # instantiate our borg wrapper
        self.borg = Borg(self.logger, self.json_callback, self)

        # setup schedule that will regularily execute backups
        self.sched = sched.scheduler()

        # extract all sections beginning with 'repo-'
        self.repos = [
            self.config[repo] for repo in self.config.sections()
            if repo.startswith('repo-')
        ]

        for repo in self.repos:
            # schedule backups now, will reschedule itself
            self.handle_repo(repo)

        while True:
            Gtk.main_iteration_do(False)
            self.sched.run(blocking=False)

            time.sleep(1)
Ejemplo n.º 10
0
 def test_borg_and_childshare_share_common_state(self):
     a = Borg('Mark')
     c = ChildShare('Paul', color='red')
     self.assertEqual(a.state, c.state)
Ejemplo n.º 11
0
 def test_two_borgs_share_common_state(self):
     a = Borg('Mark')
     b = Borg('Luke')
     self.assertEqual(a.state, b.state)
Ejemplo n.º 12
0
 def test_two_borgs_have_different_identity(self):
     a = Borg('Mark')
     b = Borg('Luke')
     self.assertIsNot(a, b)