def test_create_v3_community_2(self, *args): set_module_args( dict(version='v3', access='ro', snmp_username='******', snmp_auth_protocol='md5', snmp_auth_password='******', snmp_privacy_protocol='des', snmp_privacy_password='******', state='present', partition='Common', provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_if=self.spec.required_if) m1 = V2Manager(module=module) # Override methods to force specific logic in the module to happen m1.exists = Mock(side_effect=[False, True]) m1.create_on_device = Mock(return_value=True) m0 = ModuleManager(module=module) m0.get_manager = Mock(return_value=m1) with pytest.raises(F5ModuleError) as ex: m0.exec_module() assert 'oid must be specified when creating a new v3 community.' == str( ex.value)
def test_create_v3_community_1(self, *args): set_module_args( dict(version='v3', oid='.1', access='ro', snmp_username='******', snmp_auth_protocol='md5', snmp_auth_password='******', snmp_privacy_protocol='des', snmp_privacy_password='******', state='present', partition='Common', provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_if=self.spec.required_if) m1 = V2Manager(module=module) # Override methods to force specific logic in the module to happen m1.exists = Mock(side_effect=[False, True]) m1.create_on_device = Mock(return_value=True) m0 = ModuleManager(module=module) m0.get_manager = Mock(return_value=m1) results = m0.exec_module() assert results['changed'] is True