diff --git a/CHANGELOG.md b/CHANGELOG.md index 6045d552cada022af5afe1d4969ec1fda3520185..a60110a61278de6979d25c17937617ae79a0cf7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,27 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [Unreleased] ## ### Added ### +### Changed ### + +### Deprecated ### + +### Removed ### + +### Fixed ### + +### Security ### + +## [0.3.0] - 2020-04-24## + +### Added ### + * `apiutils.apply_to_ids` -- a helper which applies a function to all ids which are used by an entity (own entity, parents, properties, references etc.). @@ -21,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * import bugs in apiutils -## [0.2.4] +## [0.2.4] -- 2020-04-23 ### Added diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py index cda2c09b001dc4a236bf0aa1c9dbd57e3b611096..bd279fcfe5c394b9b5cff787169cff5b9f2d3031 100644 --- a/src/caosdb/apiutils.py +++ b/src/caosdb/apiutils.py @@ -5,6 +5,8 @@ # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> +# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -686,6 +688,7 @@ def apply_to_ids(entities, func): for entity in entities: _apply_to_ids_of_entity(entity, func) + def _apply_to_ids_of_entity(entity, func): entity.id = func(entity.id) diff --git a/unittests/test_apiutils.py b/unittests/test_apiutils.py index 6705cdeb83cd489dc91eb3d0722993cc722555ba..6d7581478e377ce6b41e8a00a2d47bb404d55a0b 100644 --- a/unittests/test_apiutils.py +++ b/unittests/test_apiutils.py @@ -5,6 +5,8 @@ # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> +# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -48,7 +50,7 @@ def test_pickle_object(): def test_apply_to_ids(): parent = db.RecordType(id=3456) rec = db.Record(id=23) - p = db.Property(id=23345, datatype = db.INTEGER) + p = db.Property(id=23345, datatype=db.INTEGER) rec.add_parent(parent) rec.add_property(p) diff --git a/unittests/test_entity.py b/unittests/test_entity.py index 64f18039f4370c2b0be30b2f2cf309ac858bd1ab..d877e1ab7267977a7e73d65033d6f02c16ea5521 100644 --- a/unittests/test_entity.py +++ b/unittests/test_entity.py @@ -32,14 +32,12 @@ from caosdb.connection.mockup import MockUpServerConnection class TestEntity(unittest.TestCase): - def setUp(self): self.assertIsNotNone(Entity) configure_connection(url="unittests", username="testuser", password="testpassword", timeout=200, implementation=MockUpServerConnection) - def test_instance_variables(self): entity = Entity() self.assertTrue(hasattr(entity, "role")) @@ -49,13 +47,11 @@ class TestEntity(unittest.TestCase): self.assertTrue(hasattr(entity, "parents")) self.assertTrue(hasattr(entity, "properties")) - def test_role(self): entity = Entity(role="TestRole") self.assertEqual(entity.role, "TestRole") entity.role = "TestRole2" self.assertEqual(entity.role, "TestRole2") - def test_instanciation(self): self.assertRaises(Exception, Entity())