def test_find_by_id(self):
        session_maker = MagicMock(spec=SessionMaker)
        session = MagicMock(spec=scoped_session)
        to_test = ALAOccurrenceDAO(session_maker)

        to_return = ALAOccurrence(None, None, None)
        to_return.id = 1

        session_maker.generate_session.return_value = session
        session.query.return_value.get.return_value = to_return

        out = to_test.find_by_id(1)
        self.assertIs(to_return, out)
        session.query.assert_called_with(ALAOccurrence)
        session.query.return_value.get.assert_called_with(1)
    def test_create_new(self):
        lsid = 'some lsid'
        occurrence_path = '/path/to/occurrence/file'
        metadata_path = 'path/to/metadata/file'

        session_maker = MagicMock(spec=SessionMaker)
        session = MagicMock(spec=scoped_session)
        to_test = ALAOccurrenceDAO(session_maker)

        session_maker.generate_session.return_value = session

        out = to_test.create_new(lsid, occurrence_path, metadata_path)

        matcher = self.ALAOccurrenceMatcher(lsid, occurrence_path, metadata_path)
        session.add.assert_called_with(matcher)
        session.flush.assert_called()
        session.expunge.assert_called_with(matcher)

        self.assertIsNotNone(out)
        self.assertEqual(lsid, out.lsid)
        self.assertEqual(occurrence_path, out.occurrence_path)
        self.assertEqual(metadata_path, out.metadata_path)