def test_create_datasource_format_int_value_when_string(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if (cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description' ): return { "outcome": "success", "result": { "attributes": { "min-pool-size": { "type": "INT" } } }, } self.org_run_operation.side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties["min-pool-size"] = "15" jboss7.create_datasource(self.jboss_config, "appDS", datasource_properties) self.org_run_operation.assert_called_with( self.jboss_config, '/subsystem=datasources/data-source="appDS":add(min-pool-size=15)', fail_on_error=False, )
def test_create_datasource_all_properties_included(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return {'outcome': 'success', 'result': { 'attributes': { 'driver-name': {'type': 'STRING'}, 'connection-url': {'type': 'STRING'}, 'jndi-name': {'type': 'STRING'}, 'user-name': {'type': 'STRING'}, 'password': {'type': 'STRING'} } } } self.org_run_operation.side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['driver-name'] = 'mysql' datasource_properties['connection-url'] = 'jdbc:mysql://localhost:3306/app' datasource_properties['jndi-name'] = 'java:jboss/datasources/appDS' datasource_properties['user-name'] = 'app' datasource_properties['password'] = '******' jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) self.org_run_operation.assert_called_with(self.jboss_config, '/subsystem=datasources/data-source="appDS":add(driver-name="mysql",connection-url="jdbc:mysql://localhost:3306/app",jndi-name="java:jboss/datasources/appDS",user-name="app",password="******")', fail_on_error=False)
def test_create_datasource_all_properties_included(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if ( cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description' ): return { "outcome": "success", "result": { "attributes": { "driver-name": {"type": "STRING"}, "connection-url": {"type": "STRING"}, "jndi-name": {"type": "STRING"}, "user-name": {"type": "STRING"}, "password": {"type": "STRING"}, } }, } self.org_run_operation.side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties["driver-name"] = "mysql" datasource_properties["connection-url"] = "jdbc:mysql://localhost:3306/app" datasource_properties["jndi-name"] = "java:jboss/datasources/appDS" datasource_properties["user-name"] = "app" datasource_properties["password"] = "******" jboss7.create_datasource(self.jboss_config, "appDS", datasource_properties) self.org_run_operation.assert_called_with( self.jboss_config, '/subsystem=datasources/data-source="appDS":add(driver-name="mysql",connection-url="jdbc:mysql://localhost:3306/app",jndi-name="java:jboss/datasources/appDS",user-name="app",password="******")', fail_on_error=False, )
def test_create_datasource_format_boolean_value_when_boolean(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if (cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description' ): return { "outcome": "success", "result": { "attributes": { "use-ccm": { "type": "BOOLEAN" } } }, } self.org_run_operation.side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties["use-ccm"] = True jboss7.create_datasource(self.jboss_config, "appDS", datasource_properties) self.org_run_operation.assert_called_with( self.jboss_config, '/subsystem=datasources/data-source="appDS":add(use-ccm=true)', fail_on_error=False, )
def test_create_datasource_format_int_value_when_string(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return { 'outcome': 'success', 'result': { 'attributes': { 'min-pool-size': { 'type': 'INT' } } } } __salt__['jboss7_cli.run_operation'].side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['min-pool-size'] = '15' jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) __salt__['jboss7_cli.run_operation'].assert_called_with( self.jboss_config, '/subsystem=datasources/data-source="appDS":add(min-pool-size=15)', fail_on_error=False)
def test_create_datasource_format_boolean_value_when_boolean(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return { 'outcome': 'success', 'result': { 'attributes': { 'use-ccm': { 'type': 'BOOLEAN' } } } } __salt__['jboss7_cli.run_operation'].side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['use-ccm'] = True jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) __salt__['jboss7_cli.run_operation'].assert_called_with( self.jboss_config, '/subsystem=datasources/data-source="appDS":add(use-ccm=true)', fail_on_error=False)
def test_create_datasource_all_properties_included(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return {'outcome': 'success', 'result': { 'attributes': { 'driver-name': {'type': 'STRING'}, 'connection-url': {'type': 'STRING'}, 'jndi-name': {'type': 'STRING'}, 'user-name': {'type': 'STRING'}, 'password': {'type': 'STRING'} } } } __salt__['jboss7_cli.run_operation'].side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['driver-name'] = 'mysql' datasource_properties['connection-url'] = 'jdbc:mysql://localhost:3306/app' datasource_properties['jndi-name'] = 'java:jboss/datasources/appDS' datasource_properties['user-name'] = 'app' datasource_properties['password'] = '******' jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) __salt__['jboss7_cli.run_operation'].assert_called_with(self.jboss_config, '/subsystem=datasources/data-source="appDS":add(driver-name="mysql",connection-url="jdbc:mysql://localhost:3306/app",jndi-name="java:jboss/datasources/appDS",user-name="app",password="******")', fail_on_error=False)
def test_create_datasource_format_int_value_when_string(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return {'outcome': 'success', 'result': { 'attributes': { 'min-pool-size': {'type': 'INT'} } } } __salt__['jboss7_cli.run_operation'].side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['min-pool-size'] = '15' jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) __salt__['jboss7_cli.run_operation'].assert_called_with(self.jboss_config, '/subsystem=datasources/data-source="appDS":add(min-pool-size=15)', fail_on_error=False)
def test_create_datasource_format_boolean_value_when_boolean(self): def cli_command_response(jboss_config, cli_command, fail_on_error=False): if cli_command == '/subsystem=datasources/data-source="appDS":read-resource-description': return {'outcome': 'success', 'result': { 'attributes': { 'use-ccm': {'type': 'BOOLEAN'} } } } __salt__['jboss7_cli.run_operation'].side_effect = cli_command_response datasource_properties = OrderedDict() datasource_properties['use-ccm'] = True jboss7.create_datasource(self.jboss_config, 'appDS', datasource_properties) __salt__['jboss7_cli.run_operation'].assert_called_with(self.jboss_config, '/subsystem=datasources/data-source="appDS":add(use-ccm=true)', fail_on_error=False)