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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
ebb5e9ec
Commit
ebb5e9ec
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX: caching of inserts is not implemented: adjust accordingly
parent
523ff91a
No related branches found
No related tags found
2 merge requests
!53
Release 0.1
,
!32
ENH: add security levels that may prevent updates or inserts
Pipeline
#26557
failed
3 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/crawl.py
+6
-3
6 additions, 3 deletions
src/caoscrawler/crawl.py
unittests/test_tool.py
+10
-7
10 additions, 7 deletions
unittests/test_tool.py
with
16 additions
and
10 deletions
src/caoscrawler/crawl.py
+
6
−
3
View file @
ebb5e9ec
...
@@ -777,7 +777,10 @@ class Crawler(object):
...
@@ -777,7 +777,10 @@ class Crawler(object):
if
securityMode
.
value
>
SecurityMode
.
RETRIEVE
.
value
:
if
securityMode
.
value
>
SecurityMode
.
RETRIEVE
.
value
:
db
.
Container
().
extend
(
to_be_inserted
).
insert
()
db
.
Container
().
extend
(
to_be_inserted
).
insert
()
elif
run_id
is
not
None
:
elif
run_id
is
not
None
:
raise
NotImplementedError
(
"
Caching forbidden inserts is currently not implemented
"
)
raise
RuntimeError
(
"
You must not insert Entities since the Crawler was startet
"
"
with RETRIEVE only mode.
"
)
# Caching forbidden inserts is currently not implemented
# cache = Cache()
# cache = Cache()
# cache.insert(to_be_inserted, run_id)
# cache.insert(to_be_inserted, run_id)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_tool.py
+
10
−
7
View file @
ebb5e9ec
...
@@ -594,7 +594,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -594,7 +594,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
# trivial case: nothing to do
# trivial case: nothing to do
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
assert_not_called
()
insmock
.
assert_not_called
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
...
@@ -604,11 +604,14 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -604,11 +604,14 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
# remove one element
# remove one element
del
ident
.
_records
[
-
1
]
del
ident
.
_records
[
-
1
]
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
# insert forbidden
with
pytest
.
raises
(
RuntimeError
)
as
excinfo
:
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
assert_not_called
()
insmock
.
assert_not_called
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
assert
updateCacheMock
.
call_count
==
1
# as long as caching of inserts is not implemented this is not called
updateCacheMock
.
assert_not_called
()
# reset counts
# reset counts
reset_mocks
([
updateCacheMock
,
insmock
,
upmock
])
reset_mocks
([
updateCacheMock
,
insmock
,
upmock
])
# restore original ident
# restore original ident
...
@@ -618,7 +621,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -618,7 +621,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
RETRIEVE
,
ident
)
# change one element
# change one element
change_non_identifiable_prop
(
ident
)
change_non_identifiable_prop
(
ident
)
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
assert_not_called
()
insmock
.
assert_not_called
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
...
@@ -632,7 +635,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -632,7 +635,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
INSERT
,
ident
)
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
INSERT
,
ident
)
# remove one element
# remove one element
del
ident
.
_records
[
-
1
]
del
ident
.
_records
[
-
1
]
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
assert_called_once
()
insmock
.
assert_called_once
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
...
@@ -646,7 +649,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -646,7 +649,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
INSERT
,
ident
)
crawler
=
prepare_crawler_with_sec_mode
(
SecurityMode
.
INSERT
,
ident
)
# change one element
# change one element
change_non_identifiable_prop
(
ident
)
change_non_identifiable_prop
(
ident
)
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
assert_not_called
()
insmock
.
assert_not_called
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
...
@@ -661,7 +664,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
...
@@ -661,7 +664,7 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
# change two elements
# change two elements
change_non_identifiable_prop
(
ident
)
change_non_identifiable_prop
(
ident
)
change_identifiable_prop
(
ident
)
change_identifiable_prop
(
ident
)
insl
,
updl
=
crawler
.
synchronize
(
commit_changes
=
True
)
crawler
.
synchronize
(
commit_changes
=
True
)
assert
crawler
.
run_id
is
not
None
assert
crawler
.
run_id
is
not
None
insmock
.
asser_called_once
()
insmock
.
asser_called_once
()
upmock
.
assert_not_called
()
upmock
.
assert_not_called
()
...
...
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