Ejemplo n.º 1
0
    def test_guess_success(self, mock_guess, mock_metadata):
        mock_metadata.return_value = self.metadata
        mock_guess.return_value = lib_ra.ResourceAgent(
            self.lib_env.cmd_runner(), "ocf:test:Dummy")

        self.assertEqual(lib.describe_agent(self.lib_env, "dummy"),
                         self.description)

        self.assertEqual(len(mock_metadata.mock_calls), 1)
        mock_guess.assert_called_once_with("mock_runner", "dummy")
Ejemplo n.º 2
0
    def test_behaves_like_a_proper_agent(self, load_metadata):
        name =  "ocf:heartbeat:Absent"
        runner = mock.MagicMock(spec_set=CommandRunner)
        load_metadata.return_value = "<resource-agent/>"

        agent = lib_ra.ResourceAgent(runner, name)
        absent = lib_ra.AbsentResourceAgent(runner, name)

        #metadata are valid
        absent.validate_metadata()
        self.assertTrue(absent.is_valid_metadata())

        self.assertEqual(agent.get_name(), absent.get_name())
        self.assertEqual(
            agent.get_description_info(), absent.get_description_info()
        )
        self.assertEqual(agent.get_full_info(), absent.get_full_info())
        self.assertEqual(agent.get_shortdesc(), absent.get_shortdesc())
        self.assertEqual(agent.get_longdesc(), absent.get_longdesc())
        self.assertEqual(agent.get_parameters(), absent.get_parameters())
        self.assertEqual(agent.get_actions(), absent.get_actions())
        self.assertEqual(([], []), absent.validate_parameters_values({
            "whatever": "anything"
        }))
Ejemplo n.º 3
0
 def test_does_not_raise_on_valid_name(self):
     lib_ra.ResourceAgent(mock.MagicMock(), "formal:valid:name")
Ejemplo n.º 4
0
 def test_raises_on_invalid_name(self):
     self.assertRaises(
         lib_ra.InvalidResourceAgentName,
         lambda: lib_ra.ResourceAgent(mock.MagicMock(), "invalid_name")
     )