# Path: kinto-remote-settings/tests/signer/support.py
# class BaseWebTest(CoreWebTest):
#     def __init__(self, *args, **kwargs):
#     def get_app_settings(cls, extras=None):


import datetime
import unittest
import pytest
from unittest import mock
from kinto.core.storage.exceptions import RecordNotFoundError
from kinto_remote_settings.signer.updater import LocalUpdater
from kinto_remote_settings.signer.utils import STATUS
from .support import DummyRequest
        self.updater.create_destination(request)
        request.registry.storage.create.assert_any_call(
            resource_name="collection",
            parent_id=bucket_id,
            obj={"id": "destcollection"},
        )

    def test_sign_and_update_destination(self):
        records = [
            {"id": idx, "foo": "bar %s" % idx, "last_modified": idx}
            for idx in range(1, 3)
        ]
        self.storage.list_all.return_value = records

        self.patch(self.storage, "update_records")
        self.patch(self.updater, "get_destination_records", return_value=([], "0"))
        self.patch(self.updater, "push_records_to_destination")
        self.patch(self.updater, "set_destination_signature")

        self.updater.sign_and_update_destination(DummyRequest(), {"id": "source"})

        assert self.updater.get_destination_records.call_count == 1
        assert self.updater.push_records_to_destination.call_count == 1
        assert self.updater.set_destination_signature.call_count == 1

    def test_refresh_signature_does_not_push_records(self):
        self.storage.list_all.return_value = []
        self.patch(self.updater, "set_destination_signature")
        self.patch(self.updater, "push_records_to_destination")


# Path: kinto-remote-settings/tests/signer/support.py
# class BaseWebTest(CoreWebTest):
#     def __init__(self, *args, **kwargs):
#     def get_app_settings(cls, extras=None):


# Path: kinto-remote-settings/tests/signer/test_updater.py
import datetime
import unittest
import pytest
from unittest import mock
from kinto.core.storage.exceptions import RecordNotFoundError
from kinto_remote_settings.signer.updater import LocalUpdater
from kinto_remote_settings.signer.utils import STATUS
from .support import DummyRequest

        self.updater.create_destination(request)
        request.registry.storage.create.assert_any_call(
            resource_name="collection",
            parent_id=bucket_id,
            obj={"id": "destcollection"},
        )

    def test_sign_and_update_destination(self):
        records = [
            {"id": idx, "foo": "bar %s" % idx, "last_modified": idx}
            for idx in range(1, 3)
        ]
        self.storage.list_all.return_value = records

        self.patch(self.storage, "update_records")
        self.patch(self.updater, "get_destination_records", return_value=([], "0"))
        self.patch(self.updater, "push_records_to_destination")
        self.patch(self.updater, "set_destination_signature")

        self.updater.sign_and_update_destination(DummyRequest(), {"id": "source"})

        assert self.updater.get_destination_records.call_count == 1
        assert self.updater.push_records_to_destination.call_count == 1
        assert self.updater.set_destination_signature.call_count == 1

    def test_refresh_signature_does_not_push_records(self):
        self.storage.list_all.return_value = []
        self.patch(self.updater, "set_destination_signature")
        self.patch(self.updater, "push_records_to_destination")


        self.updater.refresh_signature(DummyRequest(), "signed")