def test_root_eq():
    # two different uuids
    assert RootAnalysis() != RootAnalysis()
    root = RootAnalysis()
    # same uuids
    assert root == root.copy()
    # invalid compare
    assert root != object()
    # same uuid different version
    root = RootAnalysis()
    modified_root = root.copy()
    modified_root.version = str(uuid.uuid4())
    assert root != modified_root
    # same uuid same version
    root.version = modified_root.version
    assert root == modified_root
    async def i_update_root_analysis(self, root: RootAnalysis) -> bool:
        # when we update we also update the version
        new_version = str(uuid.uuid4())
        async with self.get_db() as db:
            result = await db.execute(
                update(RootAnalysisTracking).values(
                    version=new_version, json_data=root.to_json(exclude_analysis_details=True)
                )
                # so the version has to match for the update to work
                .where(and_(RootAnalysisTracking.uuid == root.uuid, RootAnalysisTracking.version == root.version))
            )
            await db.commit()

        if result.rowcount == 0:
            # if the version doesn't match then the update fails
            return False

        root.version = new_version
        return True
    async def i_track_root_analysis(self, root: RootAnalysis) -> bool:
        """Tracks the given root to the given RootAnalysis uuid."""
        version = root.version
        if version is None:
            version = str(uuid.uuid4())

        try:
            async with self.get_db() as db:
                await db.execute(
                    insert(RootAnalysisTracking).values(
                        uuid=root.uuid, version=version, json_data=root.to_json(exclude_analysis_details=True)
                    )
                )
                await db.commit()

            root.version = version
            return True
        except sqlalchemy.exc.IntegrityError:
            return False