Coverage for tests/test_transfer.py: 36%
26 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-26 13:07 +0000
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-26 13:07 +0000
1# This file is part of daf_relation.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://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 <http://www.gnu.org/licenses/>.
22from __future__ import annotations
24import unittest
26from lsst.daf.relation import Transfer, iteration, tests
29class TransferTestCase(tests.RelationTestCase):
30 """Tests for the Transfer operation and relations based on it."""
32 def setUp(self) -> None:
33 self.a = tests.ColumnTag("a")
34 self.source_engine = iteration.Engine(name="source")
35 self.destination_engine = iteration.Engine(name="destination")
36 self.leaf = self.source_engine.make_leaf(
37 {self.a}, payload=iteration.RowSequence([{self.a: 0}, {self.a: 1}]), name="leaf"
38 )
40 def test_attributes(self) -> None:
41 """Check that all UnaryOperation and Relation attributes have the
42 expected values.
43 """
44 relation = self.leaf.transferred_to(self.destination_engine)
45 assert isinstance(relation, Transfer)
46 self.assertEqual(relation.columns, self.leaf.columns)
47 self.assertEqual(relation.engine, self.destination_engine)
48 self.assertEqual(relation.min_rows, self.leaf.min_rows)
49 self.assertEqual(relation.max_rows, self.leaf.max_rows)
50 self.assertFalse(relation.is_locked)
51 self.assertTrue(relation.destination, self.destination_engine)
53 def test_apply_simplify(self) -> None:
54 """Test simplification logic in Transfer.apply."""
55 self.assert_relations_equal(self.leaf.transferred_to(self.source_engine), self.leaf)
56 self.assert_relations_equal(
57 self.leaf.transferred_to(self.destination_engine).transferred_to(self.source_engine), self.leaf
58 )
60 def test_str(self) -> None:
61 """Test str(Transfer) and
62 str(UnaryOperationRelation[Transfer]).
63 """
64 relation = self.leaf.transferred_to(self.destination_engine)
65 self.assertEqual(str(relation), f"→[destination]({self.leaf})")
68if __name__ == "__main__": 68 ↛ 69line 68 didn't jump to line 69, because the condition on line 68 was never true
69 unittest.main()