Exemple #1
0
def test_sync_records_scrap_information_for_plugins():
    with mock.patch('xml2kinto.__main__.scrap_details_from_amo') as fetch:
        with mock.patch('xml2kinto.__main__.get_xml_records',
                        return_value=mock.sentinel.xml_records):
            with mock.patch('xml2kinto.__main__.get_kinto_records',
                            return_value=mock.sentinel.kinto_records):
                with mock.patch('xml2kinto.__main__.get_diff',
                                return_value=(
                                    mock.sentinel.to_create,
                                    mock.sentinel.to_delete)):
                    with mock.patch('xml2kinto.__main__.push_changes'):
                        main.sync_records(
                            mock.sentinel.fields, mock.sentinel.filename,
                            mock.sentinel.xpath, mock.sentinel.client,
                            mock.sentinel.bucket, mock.sentinel.collection,
                            with_scrapping=True)

                        fetch.assert_called_with(mock.sentinel.to_create)
def test_sync_records_scrap_information_for_plugins():
    with mock.patch("xml2kinto.__main__.scrap_details_from_amo") as fetch:
        with mock.patch("xml2kinto.__main__.get_xml_records", return_value=mock.sentinel.xml_records):
            with mock.patch("xml2kinto.__main__.get_kinto_records", return_value=mock.sentinel.kinto_records):
                with mock.patch(
                    "xml2kinto.__main__.get_diff", return_value=(mock.sentinel.to_create, mock.sentinel.to_delete)
                ):
                    with mock.patch("xml2kinto.__main__.push_changes"):
                        main.sync_records(
                            mock.sentinel.fields,
                            mock.sentinel.filename,
                            mock.sentinel.xpath,
                            mock.sentinel.client,
                            mock.sentinel.bucket,
                            mock.sentinel.collection,
                            with_scrapping=True,
                        )

                        fetch.assert_called_with(mock.sentinel.to_create)
Exemple #3
0
def test_sync_records_calls_the_scenario():
    with mock.patch(
            'xml2kinto.__main__.get_xml_records',
            return_value=mock.sentinel.xml_records) as get_xml_records:
        with mock.patch(
                'xml2kinto.__main__.get_kinto_records',
                return_value=mock.sentinel.kinto_records) as get_kinto_records:
            with mock.patch(
                    'xml2kinto.__main__.get_diff',
                    return_value=(
                        mock.sentinel.to_create,
                        mock.sentinel.to_delete)) as get_diff:
                with mock.patch(
                        'xml2kinto.__main__.push_changes') as push_changes:

                    main.sync_records(
                        mock.sentinel.fields, mock.sentinel.filename,
                        mock.sentinel.xpath, mock.sentinel.kinto_client,
                        mock.sentinel.bucket, mock.sentinel.collection)

                    get_xml_records.assert_called_with(
                        fields=mock.sentinel.fields,
                        filename=mock.sentinel.filename,
                        xpath=mock.sentinel.xpath)

                    get_kinto_records.assert_called_with(
                        kinto_client=mock.sentinel.kinto_client,
                        bucket=mock.sentinel.bucket,
                        collection=mock.sentinel.collection,
                        schema=None,
                        permissions=main.COLLECTION_PERMISSIONS)

                    get_diff.assert_called_with(
                        mock.sentinel.xml_records, mock.sentinel.kinto_records)
                    push_changes.assert_called_with(
                        (mock.sentinel.to_create, mock.sentinel.to_delete),
                        mock.sentinel.kinto_client,
                        bucket=mock.sentinel.bucket,
                        collection=mock.sentinel.collection,
                        to_be_signed=True)
def test_sync_records_calls_the_scenario():
    with mock.patch("xml2kinto.__main__.get_xml_records", return_value=mock.sentinel.xml_records) as get_xml_records:
        with mock.patch(
            "xml2kinto.__main__.get_kinto_records", return_value=mock.sentinel.kinto_records
        ) as get_kinto_records:
            with mock.patch(
                "xml2kinto.__main__.get_diff", return_value=(mock.sentinel.to_create, mock.sentinel.to_delete)
            ) as get_diff:
                with mock.patch("xml2kinto.__main__.push_changes") as push_changes:

                    main.sync_records(
                        mock.sentinel.fields,
                        mock.sentinel.filename,
                        mock.sentinel.xpath,
                        mock.sentinel.kinto_client,
                        mock.sentinel.bucket,
                        mock.sentinel.collection,
                    )

                    get_xml_records.assert_called_with(
                        fields=mock.sentinel.fields, filename=mock.sentinel.filename, xpath=mock.sentinel.xpath
                    )

                    get_kinto_records.assert_called_with(
                        kinto_client=mock.sentinel.kinto_client,
                        bucket=mock.sentinel.bucket,
                        collection=mock.sentinel.collection,
                        schema=None,
                        permissions=main.COLLECTION_PERMISSIONS,
                    )

                    get_diff.assert_called_with(mock.sentinel.xml_records, mock.sentinel.kinto_records)
                    push_changes.assert_called_with(
                        (mock.sentinel.to_create, mock.sentinel.to_delete),
                        mock.sentinel.kinto_client,
                        bucket=mock.sentinel.bucket,
                        collection=mock.sentinel.collection,
                        to_be_signed=True,
                    )