def METHOD_NAME():
    """Test the addition of tags to a resource."""
    client = boto3.client("ds", region_name=TEST_REGION)
    ec2_client = boto3.client("ec2", region_name=TEST_REGION)
    directory_id = create_test_directory(client, ec2_client)
    # Unknown directory ID.
    bad_id = "d-0123456789"
    with pytest.raises(ClientError) as exc:
        client.add_tags_to_resource(
            ResourceId=bad_id, Tags=[{"Key": "foo", "Value": "bar"}]
        )
    err = exc.value.response["Error"]
    assert err["Code"] == "EntityDoesNotExistException"
    assert f"Directory {bad_id} does not exist" in err["Message"]
    # Too many tags.
    tags = [
        {"Key": f"{x}", "Value": f"{x}"}
        for x in range(Directory.MAX_TAGS_PER_DIRECTORY + 1)
    ]
    with pytest.raises(ClientError) as exc:
        client.add_tags_to_resource(ResourceId=directory_id, Tags=tags)
    err = exc.value.response["Error"]
    assert err["Code"] == "TagLimitExceededException"
    assert "Tag limit exceeded" in err["Message"]
    # Bad tags.
    with pytest.raises(ClientError) as exc:
        client.add_tags_to_resource(
            ResourceId=directory_id, Tags=[{"Key": "foo!", "Value": "bar"}]
        )
    err = exc.value.response["Error"]
    assert err["Code"] == "ValidationException"
    assert (
        "1 validation error detected: Value 'foo!' at 'tags.1.member.key' "
        "failed to satisfy constraint: Member must satisfy regular "
        "expression pattern"
    ) in err["Message"]
    # Successful addition of tags.
    added_tags = [{"Key": f"{x}", "Value": f"{x}"} for x in range(10)]
    client.add_tags_to_resource(ResourceId=directory_id, Tags=added_tags)
    result = client.list_tags_for_resource(ResourceId=directory_id)
    assert len(result["Tags"]) == 10
    assert result["Tags"] == added_tags