Beispiel #1
0
    def test_only_update_notes_that_have_changed(self, mocker, test_notebook, test_tags, test_note_metadata, test_note):
        """
        Test update only changed notes.
        """
        mocker.patch('app.evernote_utils.get_note', return_value=test_note)
        mocker.spy(app.evernote_utils, 'get_note')

        # insert the requisite notebook
        load_notebook(test_notebook)
        db_notebook = Notebook.query.filter_by(guid=test_notebook.guid).first()

        # Load the test tags into the database
        load_tags(test_tags)

        # load test note into the database
        load_notes(test_note_metadata, db_notebook)
        app.evernote_utils.get_note.call_count == 1

        app.evernote_utils.get_note.reset_mock()

        # attempt note reload with no changes
        load_notes(test_note_metadata, db_notebook)
        app.evernote_utils.get_note.call_count == 1

        app.evernote_utils.get_note.reset_mock()

        # attempt note reload with a changed updated timestamp
        new_timestamp = time.time()*1000
        test_note_metadata[0].updated = new_timestamp
        test_note.updated = new_timestamp
        load_notes(test_note_metadata, db_notebook)

        app.evernote_utils.get_note.call_count == 1
Beispiel #2
0
    def test_add_note_tags(self, mocker, test_notebook, test_tags, test_note_metadata, test_note):
        """
        Test add note with tags.
        """
        mocker.patch('app.evernote_utils.get_note', return_value=test_note)

        # insert the requisite notebook
        load_notebook(test_notebook)
        db_notebook = Notebook.query.filter_by(guid=test_notebook.guid).first()

        # load all of the test tags into the database
        load_tags(test_tags)
        assert Tag.query.count() == 3

        # load test note into the database
        load_notes(test_note_metadata, db_notebook)

        # test that tag guids are equal
        instance = Note.query.first()
        assert [tag.guid for tag in instance.tags].sort() == test_note_metadata[0].tagGuids.sort()

        # add a new tag to the note
        new_tag = '02015957-f861-4750-b6cf-74f0802b4be4'
        test_note_metadata[0].tagGuids.append(new_tag)
        test_note.tagGuids.append(new_tag)
        # adding tags does not seem to change the update date

        # load test note into the database
        load_notes(test_note_metadata, db_notebook)

        # test that the tag guids are still equal
        assert new_tag in [tag.guid for tag in instance.tags]
        assert [tag.guid for tag in instance.tags] == test_note_metadata[0].tagGuids
Beispiel #3
0
    def test_load_tags(self, test_tags):
        """
        Test loading tags into the database.
        """
        dbtags = Tag.query.all()

        assert len(dbtags) == 0

        load_tags(test_tags)
        dbtags = Tag.query.all()

        assert len(dbtags) == 3