# Path: tests/conftest.py
# DEFAULT_SERVER = "http://localhost:8888/v1"
# DEFAULT_AUTH = "user:pass"
# DEFAULT_EDITOR_AUTH = "editor:pass"
# DEFAULT_REVIEWER_AUTH = "reviewer:pass"
# DEFAULT_BUCKET = "main-workspace"
# DEFAULT_COLLECTION = "product-integrity"
# def pytest_addoption(parser):
# def server(request) -> str:
# def auth(request) -> Auth:
# def editor_auth(request) -> Auth:
# def reviewer_auth(request) -> Auth:
# def source_bucket(request) -> str:
# def source_collection(request) -> str:
# def keep_existing(request) -> bool:
# def make_client(
#     server: str, source_bucket: str, source_collection: str
# ) -> ClientFactory:
#     def _make_client(auth: Auth) -> AsyncClient:
# async def flush_default_collection(
#     make_client: ClientFactory,
#     auth: Auth,
#     source_bucket: str,
#     source_collection: str,
# ):
# def verify_url(request: FixtureRequest, base_url: str):
# def firefox_options(firefox_options: Options) -> Options:
# def selenium(selenium: WebDriver) -> WebDriver:
# def create_user(request_session: requests.Session, server: str, auth: Auth):


import os
import random
import pytest
import requests
from string import hexdigits
from typing import Dict, List
from kinto_http import AsyncClient, KintoException
from kinto_http.patch_type import JSONPatch
from kinto_remote_settings.signer.backends.local_ecdsa import ECDSASigner
from kinto_remote_settings.signer.serializer import canonical_json
from .conftest import Auth, ClientFactory
    assert event_to_review["user_id"] == "account:user"
    assert event_to_review["target"]["data"]["status"] == "to-review"

    assert event_review_attrs["action"] == "update"
    assert "kinto-signer" in event_review_attrs["user_id"]
    assert (
        event_review_attrs["target"]["data"]["last_review_request_by"] == "account:user"
    )


async def test_email_plugin(make_client: ClientFactory, auth: Auth):
    # remove any existing .eml files in mail directory
    try:
        for file in os.listdir("mail"):
            os.remove(f"mail/{file}")
    except FileNotFoundError:
        pass

    client = make_client(auth)
    await client.create_bucket(id="main-workspace", if_not_exists=True)
    await client.create_collection(
        id="product-integrity", bucket="main-workspace", if_not_exists=True
    )
    await client.patch_bucket(
        id="main-workspace",
        data={
            "kinto-emailer": {
                "hooks": [
                    {
                        "event": "kinto_remote_settings.signer.events.ReviewRequested",

# Path: tests/conftest.py
# DEFAULT_SERVER = "http://localhost:8888/v1"
# DEFAULT_AUTH = "user:pass"
# DEFAULT_EDITOR_AUTH = "editor:pass"
# DEFAULT_REVIEWER_AUTH = "reviewer:pass"
# DEFAULT_BUCKET = "main-workspace"
# DEFAULT_COLLECTION = "product-integrity"
# def pytest_addoption(parser):
# def server(request) -> str:
# def auth(request) -> Auth:
# def editor_auth(request) -> Auth:
# def reviewer_auth(request) -> Auth:
# def source_bucket(request) -> str:
# def source_collection(request) -> str:
# def keep_existing(request) -> bool:
# def make_client(
#     server: str, source_bucket: str, source_collection: str
# ) -> ClientFactory:
#     def _make_client(auth: Auth) -> AsyncClient:
# async def flush_default_collection(
#     make_client: ClientFactory,
#     auth: Auth,
#     source_bucket: str,
#     source_collection: str,
# ):
# def verify_url(request: FixtureRequest, base_url: str):
# def firefox_options(firefox_options: Options) -> Options:
# def selenium(selenium: WebDriver) -> WebDriver:
# def create_user(request_session: requests.Session, server: str, auth: Auth):


# Path: tests/integration_test.py
import os
import random
import pytest
import requests
from string import hexdigits
from typing import Dict, List
from kinto_http import AsyncClient, KintoException
from kinto_http.patch_type import JSONPatch
from kinto_remote_settings.signer.backends.local_ecdsa import ECDSASigner
from kinto_remote_settings.signer.serializer import canonical_json
from .conftest import Auth, ClientFactory

    assert event_to_review["user_id"] == "account:user"
    assert event_to_review["target"]["data"]["status"] == "to-review"

    assert event_review_attrs["action"] == "update"
    assert "kinto-signer" in event_review_attrs["user_id"]
    assert (
        event_review_attrs["target"]["data"]["last_review_request_by"] == "account:user"
    )


async def test_email_plugin(make_client: ClientFactory, auth: Auth):
    # remove any existing .eml files in mail directory
    try:
        for file in os.listdir("mail"):
            os.remove(f"mail/{file}")
    except FileNotFoundError:
        pass

    client = make_client(auth)
    await client.create_bucket(id="main-workspace", if_not_exists=True)
    await client.create_collection(
        id="product-integrity", bucket="main-workspace", if_not_exists=True
    )
    await client.patch_bucket(
        id="main-workspace",
        data={
            "kinto-emailer": {
                "hooks": [
                    {
                        "event": "kinto_remote_settings.signer.events.ReviewRequested",

                        "subject": "{user_id} requested review on {bucket_id}/{collection_id}.",