Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
a6ba7f9a
Commit
a6ba7f9a
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
TST: move identifiable test to appropriate file
parent
5038827d
No related branches found
No related tags found
2 merge requests
!91
Release 0.3
,
!67
MAINT: introduce an identifiable class
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unittests/test_identifiable.py
+59
-0
59 additions, 0 deletions
unittests/test_identifiable.py
unittests/test_identified_cache.py
+0
-27
0 additions, 27 deletions
unittests/test_identified_cache.py
with
59 additions
and
27 deletions
unittests/test_identifiable.py
0 → 100644
+
59
−
0
View file @
a6ba7f9a
#!/usr/bin/env python3
# encoding: utf-8
#
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2021 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2021 Henrik tom Wörden <h.tomwoerden@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
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
"""
test identifiable module
"""
import
caosdb
as
db
from
caoscrawler.identifiable
import
Identifiable
from
caoscrawler.identified_cache
import
IdentifiedCache
def
test_create_hashable_string
():
assert
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
))
==
"
P<B>N<A>
"
assert
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
5
}))
==
"
P<B>N<A>a:5
"
a
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
4
,
'
b
'
:
5
}))
b
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
b
'
:
5
,
'
a
'
:
4
}))
assert
a
==
b
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
db
.
Record
(
id
=
12
)})
)
==
"
P<B>N<A>a:12
"
)
a
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
(
id
=
12
)]}))
assert
(
a
==
"
P<B>N<A>a:[12]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
12
]}))
==
"
P<B>N<A>a:[12]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
(
id
=
12
),
11
]})
)
==
"
P<B>N<A>a:[12, 11]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})
)
!=
Identifiable
.
_create_hashable_string
(
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})))
This diff is collapsed.
Click to expand it.
unittests/test_identified_cache.py
+
0
−
27
View file @
a6ba7f9a
...
...
@@ -33,33 +33,6 @@ from caoscrawler.identified_cache import IdentifiedCache
def
test_create_hash
():
assert
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
))
==
"
P<B>N<A>
"
assert
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
5
}))
==
"
P<B>N<A>a:5
"
a
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
4
,
'
b
'
:
5
}))
b
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
b
'
:
5
,
'
a
'
:
4
}))
assert
a
==
b
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
db
.
Record
(
id
=
12
)})
)
==
"
P<B>N<A>a:12
"
)
a
=
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
(
id
=
12
)]}))
assert
(
a
==
"
P<B>N<A>a:[12]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
12
]}))
==
"
P<B>N<A>a:[12]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
(
id
=
12
),
11
]})
)
==
"
P<B>N<A>a:[12, 11]
"
)
assert
(
Identifiable
.
_create_hashable_string
(
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})
)
!=
Identifiable
.
_create_hashable_string
(
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})))
def
test_IdentifiedCache
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment