def test_marcxml_empty_result(mocker):
    """Test if the MARCXML uploader doesn't upload empty records"""
    mocker.patch('indico_livesync.uploader.MARCXMLGenerator.objects_to_xml', return_value=None)
    mocker.patch.object(MARCXMLUploader, 'upload_xml', autospec=True)
    uploader = MARCXMLUploader(MagicMock())
    uploader.run_initial([1])
    assert not uploader.upload_xml.called
Exemplo n.º 2
0
def test_marcxml_empty_result(mocker):
    """Test if the MARCXML uploader doesn't upload empty records"""
    mocker.patch("indico_livesync.uploader.MARCXMLGenerator.objects_to_xml", return_value=None)
    mocker.patch.object(MARCXMLUploader, "upload_xml", autospec=True)
    uploader = MARCXMLUploader(MagicMock())
    uploader.run_initial([1])
    assert not uploader.upload_xml.called
Exemplo n.º 3
0
def test_marcxml_run(mocker):
    """Text if the MARCXML uploader uses the correct function"""
    mocker.patch("indico_livesync.uploader.db")
    mocker.patch.object(MARCXMLUploader, "upload_xml", autospec=True)
    mxg = mocker.patch("indico_livesync.uploader.MARCXMLGenerator")
    uploader = MARCXMLUploader(MagicMock())
    uploader.run([LiveSyncQueueEntry(change=ChangeType.created)])
    assert mxg.records_to_xml.called
    assert not mxg.objects_to_xml.called
    assert uploader.upload_xml.called
    mxg.reset_mock()
    uploader.run_initial([1])
    assert not mxg.records_to_xml.called
    assert mxg.objects_to_xml.called
    assert uploader.upload_xml.called
def test_marcxml_run(mocker, db, dummy_event, dummy_agent):
    """Text if the MARCXML uploader uses the correct function"""
    mocker.patch('indico_livesync.uploader.db')
    mocker.patch.object(MARCXMLUploader, 'upload_xml', autospec=True)
    mxg = mocker.patch('indico_livesync.uploader.MARCXMLGenerator')

    entry = LiveSyncQueueEntry(change=ChangeType.created, type=EntryType.event, event=dummy_event,
                               agent=dummy_agent)
    db.session.add(entry)
    db.session.flush()

    uploader = MARCXMLUploader(MagicMock())
    uploader.run([entry])
    assert mxg.records_to_xml.called
    assert not mxg.objects_to_xml.called
    assert uploader.upload_xml.called
    mxg.reset_mock()
    uploader.run_initial([1])
    assert not mxg.records_to_xml.called
    assert mxg.objects_to_xml.called
    assert uploader.upload_xml.called