def runTest(self):
        maintenance_obj = Message(self.class_params['sid'],
                                  self.class_params['data'],
                                  self.class_params['cmd'])

        # Check the expected message returned
        self.assertEqual(maintenance_obj.message, self.expected_msg)

        # Check the command
        obj_details = maintenance_obj.details(self.class_params['cmd'], None)
        self.assertIn(self.expected_details_cmd, obj_details)
Пример #2
0
    def runTest(self, get_server_name_mock):
        get_server_name_mock.return_value = self.SERVER_NAME
        maintenance_obj = Message(self.class_params['sid'],
                                  self.class_params['data'],
                                  self.class_params['cmd'])

        # Check the expected message returned
        self.assertEqual(maintenance_obj.message, self.expected_msg)

        # Check the command
        obj_details = maintenance_obj.details(self.class_params['cmd'], None)
        self.assertIn(self.expected_details_cmd, obj_details['query'])
Пример #3
0
    def runTest(self):
        maintenance_obj = Message(
            self.class_params['sid'],
            self.class_params['data'],
            self.class_params['cmd']
        )

        # Check the expected message returned
        self.assertEqual(maintenance_obj.message, self.extected_msg)

        # Check the command
        obj_details = maintenance_obj.details(self.class_params['cmd'], None)
        self.assertIn(self.expetced_details_cmd, obj_details)
Пример #4
0
    def runTest(self, current_user_mock, server_mock, db_mock,
                current_app_mock, popen_mock):
        current_user_mock.id = 1
        current_app_mock.PGADMIN_RUNTIME = False

        class TestMockServer():
            def __init__(self, name, host, port):
                self.name = name
                self.host = host
                self.port = port

        def db_session_add_mock(j):
            if sys.version_info < (2, 7):
                cmd_obj = loads(str(j.desc))
            else:
                cmd_obj = loads(j.desc)
            self.assertTrue(isinstance(cmd_obj, IProcessDesc))
            self.assertEqual(cmd_obj.query, self.class_params['cmd'])
            self.assertEqual(cmd_obj.message, self.expected_msg)
            self.assertEqual(cmd_obj.data, self.class_params['data'])

        mock_obj = TestMockServer(self.class_params['username'],
                                  self.class_params['host'],
                                  self.class_params['port'])
        mock_result = server_mock.query.filter_by.return_value
        mock_result.first.return_value = mock_obj

        db_mock.session.add.side_effect = db_session_add_mock
        db_mock.session.commit = MagicMock(return_value=True)

        maintenance_obj = Message(
            self.class_params['sid'],
            self.class_params['data'],
            self.class_params['cmd']
        )

        p = BatchProcess(
            desc=maintenance_obj,
            cmd=self.class_params['cmd'],
            args=self.class_params['args']
        )

        # Check that _create_process has been called
        self.assertTrue(db_mock.session.add.called)

        # Check start method
        self._check_start(popen_mock, p, maintenance_obj)

        # Check list method
        self._check_list(p, maintenance_obj)