Coverage for tests/test_ap_verify_queries.py : 31%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of dax_ppdb. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (https://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Create test objects to store in the Ppdb.
Parameters ---------- n_objects : `int` Number of objects to create.
Returns ------- sources : `lsst.afw.table.SourceCatalog` Tests sources with filled values. """ schema = afwTable.SourceTable.makeMinimalSchema() schema.addField('nDiaSources', type="I") sources = afwTable.SourceCatalog(schema)
for src_idx in range(n_objects): src = sources.addNew() for subSchema in schema: if subSchema.getField().getTypeString() == "Angle": src[subSchema.getField().getName()] = 1 * geom.degrees else: src[subSchema.getField().getName()] = 1 src['id'] = src_idx
return sources
self.ppdbCfg = PpdbConfig() # Create DB in memory. self.ppdbCfg.db_url = 'sqlite://' self.ppdbCfg.isolation_level = "READ_UNCOMMITTED" self.ppdbCfg.dia_object_index = "baseline" self.ppdbCfg.dia_object_columns = [] self.ppdb = Ppdb( config=self.ppdbCfg, afw_schemas=dict(DiaObject=afwTable.SourceTable.makeMinimalSchema(), DiaSource=afwTable.SourceTable.makeMinimalSchema())) self.ppdb._schema.makeSchema()
del self.ppdb
value = countUnassociatedObjects(self.ppdb) self.assertEqual(value, 0)
n_created = 5 sources = createTestObjects(n_created) sources[-1]['nDiaSources'] = 2
dateTime = dafBase.DateTime(nsecs=1400000000 * 10**9) self.ppdb.storeDiaObjects(sources, dateTime.toPython())
value = countUnassociatedObjects(self.ppdb) self.assertEqual(n_created - 1, value)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |