# 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
            self.source_collection,
            {"data": {"status": "to-rollback"}},
            headers=self.headers,
        )
        events = [
            e
            for e in listener.received[before:]
            if e.payload["resource_name"] == "record"
        ]

        self.assertEqual(len(events), 3)

        self.assertEqual(events[0].payload["action"], "update")
        self.assertEqual(len(events[0].impacted_objects), 1)
        self.assertEqual(events[0].impacted_objects[0]["new"]["title"], "hello")
        self.assertEqual(events[0].impacted_objects[0]["old"]["language"], "unknown")

        self.assertEqual(events[1].payload["action"], "create")
        self.assertEqual(len(events[1].impacted_objects), 1)
        self.assertEqual(events[1].impacted_objects[0]["new"]["title"], "bonjour")
        self.assertEqual(events[1].impacted_objects[0].get("old"), None)

        self.assertEqual(events[2].payload["action"], "delete")
        self.assertEqual(len(events[2].impacted_objects), 1)
        self.assertEqual(
            events[2].impacted_objects[0]["old"]["title"], "some extra record"
        )
        self.assertEqual(events[2].impacted_objects[0]["new"]["deleted"], True)



# 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

            self.source_collection,
            {"data": {"status": "to-rollback"}},
            headers=self.headers,
        )
        events = [
            e
            for e in listener.received[before:]
            if e.payload["resource_name"] == "record"
        ]

        self.assertEqual(len(events), 3)

        self.assertEqual(events[0].payload["action"], "update")
        self.assertEqual(len(events[0].impacted_objects), 1)
        self.assertEqual(events[0].impacted_objects[0]["new"]["title"], "hello")
        self.assertEqual(events[0].impacted_objects[0]["old"]["language"], "unknown")

        self.assertEqual(events[1].payload["action"], "create")
        self.assertEqual(len(events[1].impacted_objects), 1)
        self.assertEqual(events[1].impacted_objects[0]["new"]["title"], "bonjour")
        self.assertEqual(events[1].impacted_objects[0].get("old"), None)

        self.assertEqual(events[2].payload["action"], "delete")
        self.assertEqual(len(events[2].impacted_objects), 1)
        self.assertEqual(
            events[2].impacted_objects[0]["old"]["title"], "some extra record"
        )
        self.assertEqual(events[2].impacted_objects[0]["new"]["deleted"], True)



class SignoffEventsTest(BaseWebTest, unittest.TestCase):