def test_update_source_position(self):

        ag = AGAnalysis(self.agilepyconfPath, self.sourcesconfPath)

        ag.generateMaps()

        ag.freeSources('name == "2AGLJ2021+4029"', "pos", False)

        ag.mle()

        self.assertRaises(ValueError,
                          ag.updateSourcePosition,
                          "2AGLJ2021+4029",
                          useMulti=False)

        changed = ag.updateSourcePosition("2AGLJ2021+4029",
                                          useMulti=False,
                                          glon=78.2375,
                                          glat=2.12298)
        self.assertEqual(False, changed)

        ag.freeSources('name == "2AGLJ2021+4029"', "pos", True)

        ag.mle()

        changed = ag.updateSourcePosition("2AGLJ2021+4029", useMulti=True)
        self.assertEqual(False, changed)

        ag.destroy()
    def test_source_dist_updated_after_source_position_update(self):

        test_out_dir = self.set_outputfolder("test_source_dist_updated_after_source_position_update")


        ag = AGAnalysis(self.agilepyConf, self.sourcesConfTxt)
        ag.setOptions(tmin = 433857532, tmax = 433857542, timetype = "TT", fovbinnumber=1, energybins=[[100,200]], glon = 263.55, glat = -2.78)

        source_1 = ag.selectSources(lambda name: name == self.VELA).pop()
        dist_1 = source_1.spatialModel.get("dist")["value"]

        ag.updateSourcePosition(self.VELA, glon=264, glat=-3)

        source_2 = ag.selectSources(lambda name: name == self.VELA).pop()
        dist_2 = source_2.spatialModel.get("dist")["value"]

        assert True, dist_1 != dist_2
        ag.destroy()