# Path: kinto-remote-settings/tests/signer/support.py
# class BaseWebTest(CoreWebTest):
#     api_prefix = "v1"
#     entry_point = kinto_main
#     config = "config/signer.ini"
# 
#     def __init__(self, *args, **kwargs):
#         super(BaseWebTest, self).__init__(*args, **kwargs)
#         self.headers.update(get_user_headers("mat"))
# 
#     @classmethod
#     def get_app_settings(cls, extras=None):
#         ini_path = os.path.join(here, cls.config)
#         config = configparser.ConfigParser()
#         config.read(ini_path)
#         settings = dict(config.items("app:main"))
#         settings["signer.to_review_enabled"] = False
#         return settings


import os
import unittest
from unittest import mock
from kinto.core import events as kinto_events
from kinto_remote_settings.signer import events as signer_events
from kinto_remote_settings.testing.mock_listener import listener
from pyramid.config import Configurator
from .support import BaseWebTest
        assert self.events[-1].comment == "Double check"

    def test_events_have_details_attributes(self):
        e = self.events[-1]
        assert e.request.path == "/" + self.api_prefix + self.source_collection
        assert e.payload["uri"] == self.source_collection
        assert e.payload["collection_id"] == "scid"
        assert e.impacted_objects[0]["new"]["id"] == "scid"
        assert e.resource["source"]["bucket"] == "alice"
        assert isinstance(e.original_event, kinto_events.ResourceChanged)

    def test_events_have_details_deprecated_attributes(self):
        e = self.events[-1]
        assert e.impacted_records == e.impacted_objects

    def test_review_rejected_is_triggered(self):
        self.app.patch_json(
            self.source_collection,
            {"data": {"status": "work-in-progress", "last_reviewer_comment": "Wrong"}},
            headers=self.headers,
        )
        assert isinstance(self.events[-1], signer_events.ReviewRejected)
        assert self.events[-1].comment == "Wrong"

    def test_review_cancelled_is_triggered(self):
        self.app.patch_json(
            self.source_collection,
            {"data": {"status": "to-rollback"}},
            headers=self.headers,
        )

# Path: kinto-remote-settings/tests/signer/support.py
# class BaseWebTest(CoreWebTest):
#     api_prefix = "v1"
#     entry_point = kinto_main
#     config = "config/signer.ini"
# 
#     def __init__(self, *args, **kwargs):
#         super(BaseWebTest, self).__init__(*args, **kwargs)
#         self.headers.update(get_user_headers("mat"))
# 
#     @classmethod
#     def get_app_settings(cls, extras=None):
#         ini_path = os.path.join(here, cls.config)
#         config = configparser.ConfigParser()
#         config.read(ini_path)
#         settings = dict(config.items("app:main"))
#         settings["signer.to_review_enabled"] = False
#         return settings


# Path: kinto-remote-settings/tests/signer/test_events.py
import os
import unittest
from unittest import mock
from kinto.core import events as kinto_events
from kinto_remote_settings.signer import events as signer_events
from kinto_remote_settings.testing.mock_listener import listener
from pyramid.config import Configurator
from .support import BaseWebTest

        assert self.events[-1].comment == "Double check"

    def test_events_have_details_attributes(self):
        e = self.events[-1]
        assert e.request.path == "/" + self.api_prefix + self.source_collection
        assert e.payload["uri"] == self.source_collection
        assert e.payload["collection_id"] == "scid"
        assert e.impacted_objects[0]["new"]["id"] == "scid"
        assert e.resource["source"]["bucket"] == "alice"
        assert isinstance(e.original_event, kinto_events.ResourceChanged)

    def test_events_have_details_deprecated_attributes(self):
        e = self.events[-1]
        assert e.impacted_records == e.impacted_objects

    def test_review_rejected_is_triggered(self):
        self.app.patch_json(
            self.source_collection,
            {"data": {"status": "work-in-progress", "last_reviewer_comment": "Wrong"}},
            headers=self.headers,
        )
        assert isinstance(self.events[-1], signer_events.ReviewRejected)
        assert self.events[-1].comment == "Wrong"

    def test_review_cancelled_is_triggered(self):
        self.app.patch_json(
            self.source_collection,
            {"data": {"status": "to-rollback"}},
            headers=self.headers,
        )

        assert isinstance(self.events[-1], signer_events.ReviewCanceled)