'Test config_from_template fail. Template needs vlan but none provided.'

@patch('jinja2.meta.find_undeclared_variables')
@patch('jinja2.DebugUndefined')
@patch('jinja2.Environment')
@patch('jinja2.FileSystemLoader')
def test_config_from_template_fail_no_vlan(self, mock_file_sys, mock_env, mock_debug, mock_find):

    module = Mock()
    module.params = dict(switch_name='eos', switch_port='3', server_name='new', template='jinja.j2', port_vlan=None)
    mock_file_sys.return_value = 'file'
    mock_debug.return_value = 'debug'
    template_mock = Mock()
    template_mock.render.return_value = 'interface    Ethernet3\n            description    test\n!'
    env_mock = Mock()
    env_mock.loader.get_source.return_value = ['one', 'two']
    env_mock.parse.return_value = 'parsed'
    env_mock.get_template.return_value = template_mock
    mock_env.return_value = env_mock
    mock_find.return_value = dict(server_name=None, switch_port=None, port_vlan=None)
    result = cv_server_provision.config_from_template(module)
    self.assertIsNotNone(result)
    expected = 'interface    Ethernet3\n            description    test\n!'
    self.assertEqual(result, expected)
    self.assertEqual(mock_file_sys.call_count, 1)
    self.assertEqual(mock_env.call_count, 1)
    module.fail_json.assert_called_with(msg='Template    jinja.j2    requires    a    vlan.    Please    re-run    with    vlan    number    provided.')
