def assert_dict_keys(dic, expected_keys, all_keys_required=False):
    """Method to assert that a dictionary has the expected keys and (optionally) to check if is has all the keys.

    :param dic: dictionary to checked
    :type dic: dict
    :param expected_keys: keys expected in dictionary
    :type expected_keys: list
    :param all_keys_required: (optional) to check if all keys are in the dictionary
    :type all_keys_required: bool
    :returns: check results
    """
    assert isinstance(dic, dict), 'dic should be a dictionary.'
    dict_keys = list(dic)
    if all_keys_required:
        assert not set(expected_keys).symmetric_difference(dict_keys
            ), 'Not all expected keys are in the dictionary.'
    else:
        assert set(dict_keys).issubset(expected_keys
            ), 'Dictionary keys are not a subset of the expected keys.'
