'Tests vars from role dependencies with duplicate dependencies.'

@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
def test_variable_manager_role_vars_dependencies(self):

    mock_inventory = MagicMock()
    fake_loader = DictDataLoader({'/etc/ansible/roles/common-role/tasks/main.yml': '\n                                                -    debug:    msg="{{role_var}}"\n                                                ', '/etc/ansible/roles/role1/vars/main.yml': '\n                                                role_var:    "role_var_from_role1"\n                                                ', '/etc/ansible/roles/role1/meta/main.yml': '\n                                                dependencies:\n                                                        -    {    role:    common-role    }\n                                                ', '/etc/ansible/roles/role2/vars/main.yml': '\n                                                role_var:    "role_var_from_role2"\n                                                ', '/etc/ansible/roles/role2/meta/main.yml': '\n                                                dependencies:\n                                                        -    {    role:    common-role    }\n                                                '})
    v = VariableManager(loader=fake_loader, inventory=mock_inventory)
    v._fact_cache = defaultdict(dict)
    play1 = Play.load(dict(hosts=['all'], roles=['role1', 'role2']), loader=fake_loader, variable_manager=v)
    blocks = play1.compile()
    task = blocks[1].block[0]
    res = v.get_vars(play=play1, task=task)
    self.assertEqual(res['role_var'], 'role_var_from_role1')
    task = blocks[2].block[0]
    res = v.get_vars(play=play1, task=task)
    self.assertEqual(res['role_var'], 'role_var_from_role2')
