From f9eec185bf3d857c220e5d78de75ec6713437330 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 1 Mar 2023 12:39:42 +0100 Subject: Construct Graph and Nodes with AC instead of user --- test/graph/ac/test_null.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index e35852d..7d25980 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -68,6 +68,36 @@ class TestNullAC(unittest.TestCase): self.ent_type = self.backend.schema.node(ns.bsfs.Entity) self.ent_ids = {URI('http://www.example.com/me/entity#1234'), URI('http://www.example.com/me/entity#4321')} + def test_essentials(self): + ac = NullAC(self.backend, self.user) + # equal construction means equal instance + self.assertEqual(NullAC(self.backend, self.user), NullAC(self.backend, self.user)) + self.assertEqual(hash(NullAC(self.backend, self.user)), hash(NullAC(self.backend, self.user))) + self.assertEqual(ac, NullAC(self.backend, self.user)) + self.assertEqual(hash(ac), hash(NullAC(self.backend, self.user))) + # equivalence respects type + class Foo(): pass + self.assertNotEqual(ac, 1234) + self.assertNotEqual(hash(ac), hash(1234)) + self.assertNotEqual(ac, 'hello') + self.assertNotEqual(hash(ac), hash('hello')) + self.assertNotEqual(ac, Foo()) + self.assertNotEqual(hash(ac), hash(Foo())) + # equivalence respects backend + self.assertNotEqual(ac, NullAC(SparqlStore(), self.user)) + self.assertNotEqual(hash(ac), hash(NullAC(SparqlStore(), self.user))) + # equivalence respects user + self.assertNotEqual(ac, NullAC(self.backend, URI('http://www.example.com/you'))) + self.assertNotEqual(hash(ac), hash(NullAC(self.backend, URI('http://www.example.com/you')))) + # string conversion + self.assertEqual(str(ac), f'NullAC({self.user})') + self.assertEqual(repr(ac), f'NullAC({self.user})') + # string conversion respects user + self.assertEqual(str(NullAC(self.backend, URI('http://www.example.com/you'))), + f'NullAC(http://www.example.com/you)') + self.assertEqual(repr(NullAC(self.backend, URI('http://www.example.com/you'))), + f'NullAC(http://www.example.com/you)') + def test_is_protected_predicate(self): ac = NullAC(self.backend, self.user) self.assertTrue(ac.is_protected_predicate(self.p_created)) -- cgit v1.2.3 From a5695dcc4e1be8fccd0b35ba4672cdb3c2c119d7 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 1 Mar 2023 13:06:59 +0100 Subject: minor fixes --- test/graph/ac/test_null.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index 7d25980..e33d46a 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -132,7 +132,6 @@ class TestNullAC(unittest.TestCase): ast.filter.Any(ns.bse.author, ast.filter.Equals('Me, Myself, and I'))) ac = NullAC(self.backend, self.user) self.assertEqual(query, ac.filter_read(self.ent_type, query)) - return query ## main ## -- cgit v1.2.3 From 87f437380c1dd8f420437cddc028c0f3174ee1c9 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 12:19:58 +0100 Subject: Node getters in bsfs.Graph: * Empty nodes instance (Graph.empty) * Order-preserving get query (Graph.sorted) * Collect common code in private Graph.__get * Empty query in Graph.get * Empty query in Graph.resolve.Filter * Empty query in AC: filter_read --- test/graph/ac/test_null.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index e33d46a..544a01e 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -131,7 +131,10 @@ class TestNullAC(unittest.TestCase): ast.filter.Any(ns.bse.tag, ast.filter.Is('http://example.com/tag#4321')), ast.filter.Any(ns.bse.author, ast.filter.Equals('Me, Myself, and I'))) ac = NullAC(self.backend, self.user) + # NullAC returns query self.assertEqual(query, ac.filter_read(self.ent_type, query)) + # query can be none + self.assertIsNone(ac.filter_read(self.ent_type, None)) ## main ## -- cgit v1.2.3 From 36d07cc6e0ec0f53001bfc5045437a374ebb895f Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 14:55:57 +0100 Subject: empty fetch result in Nodes --- test/graph/ac/test_null.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index 544a01e..6053f81 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -136,6 +136,15 @@ class TestNullAC(unittest.TestCase): # query can be none self.assertIsNone(ac.filter_read(self.ent_type, None)) + def test_fetch_read(self): + query = ast.fetch.All( + ast.fetch.Fetch(ns.bse.tag, ast.fetch.Value(ns.bse.label, 'tag_label')), + ast.fetch.Node(ns.bse.tag, 'tag_node'), + ast.fetch.Value(ns.bse.iso, 'iso')) + ac = NullAC(self.backend, self.user) + # NullAC returns query + self.assertEqual(query, ac.fetch_read(self.ent_type, query)) + ## main ## -- cgit v1.2.3 From 2e07f33314c238e42bfadc5f39805f93ffbc622e Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 15:10:05 +0100 Subject: removed author and license notices from individual files --- test/graph/ac/test_null.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index 6053f81..b695e7e 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -1,9 +1,4 @@ -""" -Part of the bsfs test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # imports import unittest -- cgit v1.2.3 From 4fead04055be4967d9ea3b24ff61fe37a93108dd Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sat, 4 Mar 2023 13:31:11 +0100 Subject: namespace refactoring and cleanup --- test/graph/ac/test_null.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'test/graph/ac/test_null.py') diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index b695e7e..142bc23 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -15,6 +15,8 @@ from bsfs.graph.ac.null import NullAC ## code ## +ns.bse = ns.bsfs.Entity() + class TestNullAC(unittest.TestCase): def setUp(self): self.backend = SparqlStore() @@ -22,18 +24,19 @@ class TestNullAC(unittest.TestCase): prefix rdfs: prefix xsd: - prefix bsfs: - prefix bsm: - prefix bse: + prefix bsfs: + prefix bsl: + prefix bsn: + prefix bse: bsfs:Entity rdfs:subClassOf bsfs:Node . bsfs:Tag rdfs:subClassOf bsfs:Node . xsd:string rdfs:subClassOf bsfs:Literal . - bsfs:Number rdfs:subClassOf bsfs:Literal . - xsd:integer rdfs:subClassOf bsfs:Number . + bsl:Number rdfs:subClassOf bsfs:Literal . + xsd:integer rdfs:subClassOf bsl:Number . # predicates mandated by Nodes - bsm:t_created rdfs:subClassOf bsfs:Predicate ; + bsn:t_created rdfs:subClassOf bsfs:Predicate ; rdfs:domain bsfs:Node ; rdfs:range xsd:integer ; bsfs:unique "true"^^xsd:boolean . @@ -59,7 +62,7 @@ class TestNullAC(unittest.TestCase): self.p_author = self.backend.schema.predicate(ns.bse.author) self.p_filesize = self.backend.schema.predicate(ns.bse.filesize) self.p_tag = self.backend.schema.predicate(ns.bse.tag) - self.p_created = self.backend.schema.predicate(ns.bsm.t_created) + self.p_created = self.backend.schema.predicate(ns.bsn.t_created) self.ent_type = self.backend.schema.node(ns.bsfs.Entity) self.ent_ids = {URI('http://www.example.com/me/entity#1234'), URI('http://www.example.com/me/entity#4321')} -- cgit v1.2.3