Exemplo n.º 1
0
    def __init__(self, parent, child=None, config=None):
        """Initialize the class.

        Args:
            parent: Name of parent daemon
            child: Name of child daemon
            config: Config object

        Returns:
            None

        """
        # Initialize key variables (Parent)
        if config is None:
            self.config = Config()
        else:
            self.config = config
        self.parent = parent
        self.pidfile_parent = files.pid_file(parent, self.config)
        self.lockfile_parent = files.lock_file(parent, self.config)

        # Initialize key variables (Child)
        if bool(child) is None:
            self._pidfile_child = None
        else:
            self._pidfile_child = files.pid_file(child, self.config)
Exemplo n.º 2
0
    def test___init__(self):
        """Testing method or function named __init__."""
        # Initialize key variables
        parent = 'parent'
        child = 'child'

        # Test - No Child
        tester = agent.Agent(parent, config=self.config)
        self.assertEqual(tester.parent, parent)
        expected = files.pid_file(parent, self.config)
        self.assertEqual(tester.pidfile_parent, expected)
        expected = files.lock_file(parent, self.config)
        self.assertEqual(tester.lockfile_parent, expected)
        expected = files.pid_file(None, self.config)
        self.assertEqual(tester._pidfile_child, expected)

        # Test - With Child
        tester = agent.Agent(parent, child=child, config=self.config)
        self.assertEqual(tester.parent, parent)
        expected = files.pid_file(parent, self.config)
        self.assertEqual(tester.pidfile_parent, expected)
        expected = files.lock_file(parent, self.config)
        self.assertEqual(tester.lockfile_parent, expected)
        expected = files.pid_file(child, self.config)
        self.assertEqual(tester._pidfile_child, expected)
Exemplo n.º 3
0
 def test_pid_file(self):
     """Testing function pid_file."""
     # Test
     filename = files._File(self.config)
     expected = filename.pid(self.prefix)
     result = files.pid_file(self.prefix, self.config)
     self.assertEqual(result, expected)
Exemplo n.º 4
0
    def test___init__(self):
        """Testing function __init__."""
        # Check daemon name matches agent name
        self.assertEqual(self._daemon.name, self._agent.name())

        # Checking daemon pid_file
        expected = files.pid_file(self._agent.name(), self._config)
        self.assertEqual(self._daemon.pidfile, expected)

        # Checking daemon lock_file
        expected = files.lock_file(self._agent.name(), self._config)
        self.assertEqual(self._daemon.lockfile, expected)