diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2020-09-30 12:17:35 +0000 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2020-09-30 12:17:35 +0000 |
commit | 4405523d7947c1076d0abbb51365bf5506060eb3 (patch) | |
tree | 6bf5e81ffb57b47df3d71084447c501546a8bf38 /tests/functional-tests/portal.py | |
parent | a88617112519b1764a9c7d5777e717492746bfd9 (diff) | |
parent | 1f1528c36aabb41093cb1a1e35135970a1d707cb (diff) | |
download | tracker-4405523d7947c1076d0abbb51365bf5506060eb3.tar.gz |
Merge branch 'wip/carlosg/more-tests' into 'master'
Add some more tests
See merge request GNOME/tracker!319
Diffstat (limited to 'tests/functional-tests/portal.py')
-rw-r--r-- | tests/functional-tests/portal.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/functional-tests/portal.py b/tests/functional-tests/portal.py new file mode 100644 index 000000000..a4e82820f --- /dev/null +++ b/tests/functional-tests/portal.py @@ -0,0 +1,62 @@ +# Copyright (C) 2020, Carlos Garnacho <carlosg@gnome.org> +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +""" +Test portal +""" + +from gi.repository import GLib + +import unittest + +import configuration +import fixtures + +class TestPortal(fixtures.TrackerPortalTest): + def test_01_forbidden(self): + self.start_service('org.freedesktop.Inaccessible') + self.assertRaises( + GLib.Error, self.query, + 'org.freedesktop.Inaccessible', + 'select ?u { BIND (1 AS ?u) }') + + def test_02_allowed(self): + self.start_service('org.freedesktop.PortalTest') + res = self.query( + 'org.freedesktop.PortalTest', + 'select ?u { BIND (1 AS ?u) }') + self.assertEqual(len(res), 1) + self.assertEqual(res[0][0], '1') + + def test_03_graph_access(self): + self.start_service('org.freedesktop.PortalTest') + self.update( + 'org.freedesktop.PortalTest', + 'CREATE GRAPH tracker:Disallowed;' + + 'INSERT { GRAPH tracker:Disallowed { <a> a nfo:FileDataObject } };' + + 'CREATE GRAPH tracker:Allowed;' + + 'INSERT { GRAPH tracker:Allowed { <b> a nfo:FileDataObject } }') + res = self.query( + 'org.freedesktop.PortalTest', + 'select ?u { ?u a rdfs:Resource }') + self.assertEqual(len(res), 1) + self.assertEqual(res[0][0], 'b') + + +if __name__ == '__main__': + fixtures.tracker_test_main() |