Debian Codegraph @

FaCT++.Python/pyfactxx/tests/test_d_role.py

raw symbols SCIP
1 #
2 # pyfactxx - Python interface to FaCT++ reasoner
3 #
4 # Copyright (C) 2016-2018 by Artur Wroblewski <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20
21 def test_create_data_role(reasoner):
22 """ Test creating data role. """
23 r = reasoner.data_role('R')
24 assert 'R' == r.name
25
26
27 def test_equivalent_roles(reasoner):
28 """ Test creating equivalent data roles. """
29 r1 = reasoner.data_role('R1')
30 cls = reasoner.concept('CLS')
31 reasoner.set_d_domain(r1, cls)
32
33 r2 = reasoner.data_role('R2')
34 reasoner.equal_d_roles(r1, r2)
35
36 # precondition
37 assert r1 != r2
38
39 # r1 and r2 are equivalent, so they have the same domain
40 values = reasoner.get_d_domain(r2)
41 assert 'CLS' == next(values).name
42 assert next(values, None) is None
43
44
45 def test_sub_property(reasoner):
46 """ Test creating sub-property of a data property. """
47 r = reasoner.data_role('R')
48 sub_r = reasoner.data_role('SR')
49 reasoner.implies_d_roles(sub_r, r)
50 assert reasoner.is_sub_d_role(sub_r, r)
51
52
53 def test_get_d_domain(reasoner):
54 """ Test getting data role domain. """
55 cls = reasoner.concept('CLS')
56 r = reasoner.data_role('R')
57 reasoner.set_d_domain(r, cls)
58
59 values = reasoner.get_d_domain(r)
60 assert 'CLS' == next(values).name
61 assert next(values, None) is None
62
63
64 def test_get_d_domain_top(reasoner):
65 """ Test getting data role domain when no domain set. """
66 top = reasoner.concept_top()
67 r = reasoner.data_role('R')
68 i = reasoner.individual('i')
69 reasoner.value_of_int(i, r, 1)
70
71 values = reasoner.get_d_domain(r)
72 assert [top] == list(values)
73
74 # vim: sw=4:et:ai