def test_synchronize_triggers_the_signature(self):
        push_changes(([{'id': 1, 'val': 2}], [{'id': 3, 'val': 4}]),
                     self.kinto_client, self.bucket, self.collection)

        self.kinto_client.patch_collection.assert_called_with(
            data={'status': 'to-sign'},
            bucket=mock.sentinel.bucket, collection=mock.sentinel.collection)
    def test_synchronize_create_the_batch_request(self):
        push_changes(([{'id': 1, 'val': 2}], [{'id': 3, 'val': 4}]),
                     self.kinto_client, self.bucket, self.collection)

        self.mocked_batch.create_record.assert_called_with(
            {'id': 1, 'val': 2, 'enabled': True})
        self.mocked_batch.delete_record.assert_called_with(
            {'id': 3, 'val': 4})
    def test_synchronize_triggers_the_signature(self):
        push_changes(([{
            'id': 1,
            'val': 2
        }], [{
            'id': 3,
            'val': 4
        }]), self.kinto_client, self.bucket, self.collection)

        self.kinto_client.patch_collection.assert_called_with(
            data={'status': 'to-sign'},
            bucket=mock.sentinel.bucket,
            collection=mock.sentinel.collection)
    def test_synchronize_create_the_batch_request(self):
        push_changes(([{
            'id': 1,
            'val': 2
        }], [{
            'id': 3,
            'val': 4
        }]), self.kinto_client, self.bucket, self.collection)

        self.mocked_batch.create_record.assert_called_with({
            'id': 1,
            'val': 2,
            'enabled': True
        })
        self.mocked_batch.delete_record.assert_called_with({'id': 3, 'val': 4})
Esempio n. 5
0
def sync_records(fields, filename, xpath, kinto_client, bucket, collection,
                 schema=None, with_scrapping=False, force_signature=True):
    xml_records = get_xml_records(
        fields=fields,
        filename=filename,
        xpath=xpath)
    kinto_records = get_kinto_records(
        kinto_client=kinto_client,
        bucket=bucket,
        collection=collection,
        schema=schema,
        permissions=COLLECTION_PERMISSIONS)

    to_create, to_delete = get_diff(xml_records, kinto_records)

    if with_scrapping:
        to_create = scrap_details_from_amo(to_create)

    push_changes((to_create, to_delete), kinto_client,
                 bucket=bucket, collection=collection,
                 to_be_signed=force_signature)
    def test_synchronize_does_not_triggers_the_signer_on_empty_changes(self):
        push_changes(([], []), self.kinto_client, self.bucket, self.collection)

        self.assertFalse(self.kinto_client.patch_collection.called)
    def test_synchronize_does_not_triggers_the_signer_on_empty_changes(self):
        push_changes(([], []), self.kinto_client, self.bucket, self.collection)

        self.assertFalse(self.kinto_client.patch_collection.called)