Coverage for tests/test_skyBotEphemerisQuery.py: 55%
29 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 10:45 +0000
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 10:45 +0000
1# This file is part of ap_association.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22from mock import patch
23import numpy as np
24import os
25import pandas as pd
26import unittest
28import lsst.ap.association.skyBotEphemerisQuery as ephQ
29import lsst.geom as geom
30import lsst.pipe.base as pipeBase
31from lsst.utils import getPackageDir
32import lsst.utils.tests
35class TestSkyBotEphemerisQuery(unittest.TestCase):
37 def test_skyBotConeSearch(self):
38 """Test that our parsing of SkyBot return data succeeds and produces
39 consistent hashed dataIds.
40 """
41 def requestReplace(input1, input2):
42 """Junk wrapper for replacing the external internal call with an
43 internel data load.
44 """
45 with open(os.path.join(getPackageDir("ap_association"),
46 "tests",
47 "data",
48 "testSSObjects.txt"),
49 "r") as f:
50 outputText = f.read()
51 return pipeBase.Struct(text=outputText)
52 with patch('lsst.ap.association.skyBotEphemerisQuery.requests.request',
53 new=requestReplace):
54 ephTask = ephQ.SkyBotEphemerisQueryTask()
55 testOut = ephTask._skybotConeSearch(geom.SpherePoint(0, 0, geom.degrees), 57071, 1.7)
56 testData = pd.read_parquet(
57 os.path.join(getPackageDir("ap_association"),
58 "tests",
59 "data",
60 "testSSObjects.parq")
61 )
62 self.assertEqual(len(testData), len(testOut))
63 self.assertTrue(np.all(np.equal(testData["ssObjectId"], testData["ssObjectId"])))
66class MemoryTester(lsst.utils.tests.MemoryTestCase):
67 pass
70def setup_module(module):
71 lsst.utils.tests.init()
74if __name__ == "__main__": 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 lsst.utils.tests.init()
76 unittest.main()