oldaplib 0.4.2__py3-none-any.whl → 0.4.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -418,6 +418,13 @@ class LangString(Notify):
418
418
  f'LangString parameter has wrong datatype: {type(langstring).__name__}, must be "str | Xsd_string | List[str] | Dict[Language | str, str] | LangString"')
419
419
  self.notify()
420
420
 
421
+ def remove(self, lang: Language | str):
422
+ self.__delitem__(lang)
423
+
424
+ def discard(self, lang: Language | str):
425
+ if self.get(lang) is not None:
426
+ self.__delitem__(lang)
427
+
421
428
  def undo(self) -> None:
422
429
  """
423
430
  Undo all changes made since last update/creation/read
@@ -212,16 +212,13 @@ class ResourceInstance:
212
212
  self.clear_changeset()
213
213
 
214
214
  def __setitem__(self, key: Xsd_QName, value: ValueType | Xsd | None):
215
- if self._values.get(key):
216
- self.__set_value(value, key)
217
- else:
218
- raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
215
+ self.__set_value(value, key)
219
216
 
220
217
  def __getitem__(self, key: Xsd_QName) -> ValueType | Xsd | None:
221
218
  if self._values.get(key):
222
219
  return self.__get_value(key)
223
220
  else:
224
- raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
221
+ raise OldapErrorValue(f'{self.name}: __getitem__: Property {key} does not exist.')
225
222
 
226
223
  def __delitem__(self, key: Xsd_QName):
227
224
  if self._values.get(key):
@@ -465,7 +462,7 @@ class ResourceInstance:
465
462
  self.validate_value(value, hasprop.prop)
466
463
  else:
467
464
  if isinstance(value, (list, tuple, set, ObservableSet)):
468
- for val in self._values[attr]:
465
+ for val in value:
469
466
  self.validate_value(val, hasprop.prop)
470
467
  else:
471
468
  self.validate_value(value, hasprop.prop)
oldaplib/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.2"
1
+ __version__ = "0.4.3"
@@ -18,7 +18,8 @@ from oldaplib.src.enums.language import Language
18
18
  from oldaplib.src.helpers.attributechange import AttributeChange
19
19
  from oldaplib.src.helpers.context import Context
20
20
  from oldaplib.src.helpers.langstring import LangString
21
- from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorValue, OldapErrorNoPermission, OldapErrorInUse
21
+ from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorValue, OldapErrorNoPermission, \
22
+ OldapErrorInUse, OldapErrorKey
22
23
  from oldaplib.src.role import Role
23
24
  from oldaplib.src.project import Project
24
25
  from oldaplib.src.user import User
@@ -613,6 +614,129 @@ class TestObjectFactory(unittest.TestCase):
613
614
 
614
615
  obj1.delete()
615
616
 
617
+ def test_value_modifier_C(self):
618
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
619
+ SetterTester = factory.createObjectInstance('SetterTester')
620
+ obj1 = SetterTester(stringSetter="This is a test string",
621
+ langStringSetter=LangString("C'est un teste@fr", "Dies ist eine Test-Zeichenkette@de"),
622
+ decimalSetter=Xsd_decimal(3.14),
623
+ booleanSetter=True,
624
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
625
+ obj1.create()
626
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
627
+ obj1[Xsd_QName('test:integerSetter')] = [1]
628
+ obj1.update()
629
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
630
+ self.assertEqual(obj1.integerSetter, {Xsd_int(1)})
631
+
632
+ def test_value_modifier_add_lang(self):
633
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
634
+ SetterTester = factory.createObjectInstance('SetterTester')
635
+ obj1 = SetterTester(stringSetter="This is a test string",
636
+ langStringSetter=LangString("C'est un teste@fr"),
637
+ decimalSetter=Xsd_decimal(3.14),
638
+ booleanSetter=True,
639
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
640
+ obj1.create()
641
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
642
+ obj1[Xsd_QName('test:langStringSetter')].add("Dies ist eine Test-Zeichenkette@de")
643
+ obj1.update()
644
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
645
+ self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr", "Dies ist eine Test-Zeichenkette@de"))
646
+
647
+ def test_value_modifier_remove_lang_A(self):
648
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
649
+ SetterTester = factory.createObjectInstance('SetterTester')
650
+ obj1 = SetterTester(stringSetter="This is a test string",
651
+ langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
652
+ decimalSetter=Xsd_decimal(3.14),
653
+ booleanSetter=True,
654
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
655
+ obj1.create()
656
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
657
+ del obj1[Xsd_QName('test:langStringSetter')]['de']
658
+ obj1.update()
659
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
660
+ self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr"))
661
+
662
+ def test_value_modifier_remove_lang_B(self):
663
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
664
+ SetterTester = factory.createObjectInstance('SetterTester')
665
+ obj1 = SetterTester(stringSetter="This is a test string",
666
+ langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
667
+ decimalSetter=Xsd_decimal(3.14),
668
+ booleanSetter=True,
669
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
670
+ obj1.create()
671
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
672
+ obj1[Xsd_QName('test:langStringSetter')].remove(Language.DE)
673
+ obj1.update()
674
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
675
+ self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr"))
676
+
677
+ def test_value_modifier_remove_lang_D(self):
678
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
679
+ SetterTester = factory.createObjectInstance('SetterTester')
680
+ obj1 = SetterTester(stringSetter="This is a test string",
681
+ langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
682
+ decimalSetter=Xsd_decimal(3.14),
683
+ booleanSetter=True,
684
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
685
+ obj1.create()
686
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
687
+ obj1[Xsd_QName('test:langStringSetter')].discard(Language.EN)
688
+ obj1.update()
689
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
690
+ self.assertEqual(obj1.langStringSetter, LangString("Waseliwas@de", "C'est un teste@fr"))
691
+
692
+ with self.assertRaises(OldapErrorKey):
693
+ obj1[Xsd_QName('test:langStringSetter')].remove(Language.EN)
694
+
695
+ def test_value_modifier_replace(self):
696
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
697
+ SetterTester = factory.createObjectInstance('SetterTester')
698
+ obj1 = SetterTester(stringSetter="This is a test string",
699
+ langStringSetter=LangString("C'est un teste@fr"),
700
+ decimalSetter=Xsd_decimal(3.14),
701
+ booleanSetter=True,
702
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
703
+ obj1.create()
704
+ obj1[Xsd_QName('test:langStringSetter')] = LangString("FRANCAIS@fr", "DEUTSCH@de")
705
+ obj1.update()
706
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
707
+ self.assertEqual(obj1.langStringSetter, LangString("FRANCAIS@fr", "DEUTSCH@de"))
708
+
709
+
710
+ def test_value_modifier_delete_A(self):
711
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
712
+ SetterTester = factory.createObjectInstance('SetterTester')
713
+ obj1 = SetterTester(stringSetter="This is a test string",
714
+ langStringSetter=LangString("C'est un teste@fr"),
715
+ decimalSetter=Xsd_decimal(3.14),
716
+ booleanSetter=True,
717
+ integerSetter={20200, 30300},
718
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
719
+ obj1.create()
720
+ obj1[Xsd_QName('test:integerSetter')] = None
721
+ obj1.update()
722
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
723
+ self.assertIsNone(obj1.integerSetter)
724
+
725
+ def test_value_modifier_delete_B(self):
726
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
727
+ SetterTester = factory.createObjectInstance('SetterTester')
728
+ obj1 = SetterTester(stringSetter="This is a test string",
729
+ langStringSetter=LangString("C'est un teste@fr"),
730
+ decimalSetter=Xsd_decimal(3.14),
731
+ booleanSetter=True,
732
+ integerSetter={20200, 30300},
733
+ grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
734
+ obj1.create()
735
+ del obj1[Xsd_QName('test:integerSetter')]
736
+ obj1.update()
737
+ obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
738
+ self.assertIsNone(obj1.integerSetter)
739
+
616
740
  def test_value_maxcount_mincount(self):
617
741
  factory = ResourceInstanceFactory(con=self._connection, project='test')
618
742
  Person = factory.createObjectInstance('Person')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oldaplib
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Open Media Access Server Library (Linked Open Data middleware/RESTApi)
5
5
  License: GNU Affero General Public License version 3
6
6
  Author: Lukas Rosenthaler
@@ -16,9 +16,10 @@ Requires-Dist: coverage (>=7.10.7,<8.0.0)
16
16
  Requires-Dist: isodate (>=0.7.2,<0.8.0)
17
17
  Requires-Dist: lazydocs (>=0.4.8,<0.5.0)
18
18
  Requires-Dist: mkdocs (>=1.5.3,<2.0.0)
19
- Requires-Dist: mkdocs-material (==9.6.21)
20
- Requires-Dist: mkdocstrings (>=0.30.0,<0.31.0)
21
- Requires-Dist: mkdocstrings-python (>=1.17.0,<2.0.0)
19
+ Requires-Dist: mkdocs-material (==9.7.1)
20
+ Requires-Dist: mkdocstrings (==1.0.1)
21
+ Requires-Dist: mkdocstrings-python (==2.0.1)
22
+ Requires-Dist: oldap-tools (>=0.1.2,<0.2.0)
22
23
  Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
23
24
  Requires-Dist: pymdown-extensions (>=10.10.2,<11.0.0)
24
25
  Requires-Dist: pyshacl (>=0.30.1,<0.31.0)
@@ -50,7 +50,7 @@ oldaplib/src/helpers/context.py,sha256=qWv0E_MQKzXYLIt3thd65jfgvPjNL-KQ7RzYirhtY
50
50
  oldaplib/src/helpers/convert2datatype.py,sha256=jLhcOBfsGQVwYjzvQBUbFrFWoIquS44kU81aJ5BhMaA,6447
51
51
  oldaplib/src/helpers/irincname.py,sha256=XZoV6eEsWVssvhQE9w1TD0cYDX1EYQnhN8PiU9gjvng,2473
52
52
  oldaplib/src/helpers/json_encoder.py,sha256=c78h9uf58zfLaK8X7S1KCK4otY3iEltGnPBy_5ryiCk,2135
53
- oldaplib/src/helpers/langstring.py,sha256=KfyYisMKEYstv-CUPlKkjMg9fbTjrOV3IDn2HOUfdtY,30350
53
+ oldaplib/src/helpers/langstring.py,sha256=PqHeHez81wGime2HbI4YE6d4XGsD45SUG660kyq2wXU,30546
54
54
  oldaplib/src/helpers/numeric.py,sha256=swRKU51zbwss9UDGTC6FzhTTPK_BVfy5On0KCK-zZnQ,966
55
55
  oldaplib/src/helpers/observable_dict.py,sha256=_7wYzMtna6hjngLCF-8iOYdaXztGappBZ5Jkm26FEoE,3336
56
56
  oldaplib/src/helpers/observable_set.py,sha256=aqBtZFLSG32NSFXNNYGE7RyGj0QmL2O35Khj1asnRYc,14495
@@ -64,7 +64,7 @@ oldaplib/src/helpers/tools.py,sha256=sNbiOLucTGNFzZmiWwPLFOb80VTXQH0Zd9uCGubhzAk
64
64
  oldaplib/src/iconnection.py,sha256=XlOc2Kh4tK_UOHydLQwlWjUFLUze-Aq_vEZpf9KS1-s,3677
65
65
  oldaplib/src/in_project.py,sha256=ZnfeOFwpdPh1oyC2mAGH8DnSD9afxYtvsh7_GrfGVgQ,10663
66
66
  oldaplib/src/model.py,sha256=wgvXaR2GVHk4hJxoL6rigFHwjPYEukBOjtf1Jmo-m9A,19326
67
- oldaplib/src/objectfactory.py,sha256=3xzXXVRBLernA-JD3NHZ2-FLaywWI6opWIaJfLGv2uk,85975
67
+ oldaplib/src/objectfactory.py,sha256=F8QcxKdgvtrmnRcgnSwHICQYkX13HeScF7ErBzOnug4,85841
68
68
  oldaplib/src/oldaplist.py,sha256=s5afrHtUnvDfMUFoZTt-jMxlBlmK2c0tLeTMp0KiIfg,43077
69
69
  oldaplib/src/oldaplist_helpers.py,sha256=D_X7KdFjPNlX-OwR04D6onxhFucrGo8052WuJPRjLkA,14213
70
70
  oldaplib/src/oldaplistnode.py,sha256=NnC2juEGTtEkDO6OlB9PjSw_zTF-wSsRUgEk-6VV9DA,87344
@@ -75,7 +75,7 @@ oldaplib/src/resourceclass.py,sha256=zJNWNY1TfhGs-A2HNa1DO0KAajps_1jMQsoEkUsr7P0
75
75
  oldaplib/src/role.py,sha256=AWtZx80OVERT2xbKeuP8g32VSXkm4MVlzeUWd9nh6mQ,30741
76
76
  oldaplib/src/user.py,sha256=iTJzSvR0xfc3FFkoKG-q5LptkWB_PGpRGpG-L3271z8,55833
77
77
  oldaplib/src/userdataclass.py,sha256=4kWktau9XSv5alfEVuOvikfxnSSUSKT8cw77TWdMhQM,13921
78
- oldaplib/src/version.py,sha256=Y-I6FXKes4hB39WcBm3HZ1OCtCWiErPB6YZ-YSgexuE,21
78
+ oldaplib/src/version.py,sha256=-0DFAS3GW84dLmJEuzbtUA7qvIf_cBb4LhqSg0oFfeI,21
79
79
  oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
80
  oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
81
81
  oldaplib/src/xsd/iri.py,sha256=w1Dr0z-REi7yPe3GPGnyzGrLVMvLY03kEeK-AmZ9sxw,8383
@@ -131,7 +131,7 @@ oldaplib/test/test_hasproperty.py,sha256=cU9t7uBaMxtIVbpk3UyGjPyIzQKDSS2PzqGHIIN
131
131
  oldaplib/test/test_in_project.py,sha256=OV5csuPwxcctmOM2HsB_ITmXXASRcH9-A2GlWW5foa4,7580
132
132
  oldaplib/test/test_langstring.py,sha256=37BeKiQzj63G-SyS_paK_SEG7ulRbGrE89Mz40UB_bE,15146
133
133
  oldaplib/test/test_language_in.py,sha256=ELqHO-YIsZSCPF3E3rWde4J7rERL7En7sV_pzQ00zgs,8826
134
- oldaplib/test/test_objectfactory.py,sha256=QJ4di0qJ48tVC3wPELSGMt4KoYb7wPpyk2BS-Efb2PY,48317
134
+ oldaplib/test/test_objectfactory.py,sha256=znSEy7VagIU6tcgXyw91aPMxjFNS8Nc7Ne3sJALhpno,55447
135
135
  oldaplib/test/test_observable_dict.py,sha256=GxD0sM0nsVfVRBu92SFGkJ6--YXq4ibBWI4IpjZZzDU,1396
136
136
  oldaplib/test/test_observable_set.py,sha256=JWZSoAsr8XIEBXPVgSVJjQQEEc8uSAme5IrFYLYVVXw,6313
137
137
  oldaplib/test/test_oldaplist.py,sha256=jMM3HiSFs7YcS2ltEvot6637EhK-fMV0W5DSUlFdTRI,20098
@@ -164,6 +164,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
164
164
  oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
165
165
  oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
166
166
  oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
167
- oldaplib-0.4.2.dist-info/METADATA,sha256=8sOUpxHNqa4-ldp3AtofTxcuXhIaChtz8HN5NfC-nmM,3009
168
- oldaplib-0.4.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
169
- oldaplib-0.4.2.dist-info/RECORD,,
167
+ oldaplib-0.4.3.dist-info/METADATA,sha256=K5sUH-ivSkbjm9EI2IjPFsUygs_gBmRxjfEbVIWvFQ8,3035
168
+ oldaplib-0.4.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
169
+ oldaplib-0.4.3.dist-info/RECORD,,