Skip to content
Snippets Groups Projects
Verified Commit 8b217af5 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'master' into dev

parents 25eca72d 0a6e522a
Branches
Tags
No related merge requests found
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment