Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
seda
Commits
71f04ef316cb
Commit
c064b960
authored
Apr 11, 2017
by
Sylvain Thénault
Browse files
[test/cleanup] Use .cnx instead of (repo/client)_cnx
parent
9220e0ebf255
Changes
8
Hide whitespace changes
Inline
Side-by-side
test/test_dataimport.py
View file @
71f04ef3
...
...
@@ -23,7 +23,7 @@ from cubicweb_seda import dataimport
class
ConcepSchemeImportTC
(
CubicWebTC
):
def
test_import_seda_schemes
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
dataimport
.
import_seda_schemes
(
cnx
,
lcsv_import
=
dataimport
.
lcsv_check
)
self
.
assertEqual
(
len
(
cnx
.
find
(
'ConceptScheme'
)),
18
)
...
...
test/test_diag.py
View file @
71f04ef3
...
...
@@ -23,7 +23,7 @@ from cubicweb_seda.testutils import create_archive_unit
class
CompatAnalyzerTC
(
CubicWebTC
):
def
test_rules
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
transfer
=
create
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
)
...
...
@@ -79,7 +79,7 @@ class CompatAnalyzerTC(CubicWebTC):
'rule_ref_non_rule_id'
)
def
test_custodial_history
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
transfer
=
create
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
)
...
...
@@ -115,7 +115,7 @@ class CompatAnalyzerTC(CubicWebTC):
'seda02_custodial_history_when'
)
def
test_archive_unit_reference_in_transfer
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
)
create_archive_unit
(
transfer
,
archive_unit_reference
=
True
)
...
...
@@ -124,7 +124,7 @@ class CompatAnalyzerTC(CubicWebTC):
self
.
assertDiagnostic
(
doctor
,
[
'SEDA 2.0'
],
'use_archive_unit_ref'
)
def
test_archive_unit_reference_in_archive_unit
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
)
unit
,
unit_alt
,
unit_alt_seq
=
create_archive_unit
(
transfer
)
create_archive_unit
(
unit_alt_seq
,
archive_unit_reference
=
True
)
...
...
test/test_entities.py
View file @
71f04ef3
...
...
@@ -52,7 +52,7 @@ class ContainerTC(CubicWebTC):
self
.
assertIsNone
(
entity
.
cw_adapt_to
(
'IContained'
))
def
test_container_relation
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
transfer
=
create
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
mtclv
=
create
(
'SEDAMimeTypeCodeListVersion'
,
...
...
@@ -72,7 +72,7 @@ class ContainerTC(CubicWebTC):
def
test_archive_unit_container_clone
(
self
):
"""Functional test for SEDA component clone."""
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
create_archive_unit
(
None
,
cnx
=
cnx
)
bdo
=
create_data_object
(
unit_alt_seq
)
cnx
.
commit
()
...
...
@@ -116,7 +116,7 @@ class ContainerTC(CubicWebTC):
def
test_archive_transfer_clone
(
self
):
"""Functional test for SEDA profile cloning."""
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
scheme
=
cnx
.
create_entity
(
'ConceptScheme'
,
title
=
u
'Algorithms'
)
concept
=
scheme
.
add_concept
(
u
'md5'
)
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
...
...
@@ -140,7 +140,7 @@ class ContainerTC(CubicWebTC):
def
test_container_clone_clone
(
self
):
"""Functional test for SEDA component clone."""
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
create_archive_unit
(
None
,
cnx
=
cnx
)
cnx
.
commit
()
...
...
@@ -222,7 +222,7 @@ class ITreeTC(CubicWebTC):
self
.
assertEqual
(
parent_eid
,
expected_eid
)
def
test
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
au
,
alt
,
seq
=
create_archive_unit
(
transfer
)
do_ref
=
cnx
.
create_entity
(
'SEDADataObjectReference'
,
...
...
@@ -300,13 +300,13 @@ class ParentAndContainerTC(CubicWebTC):
class
CustomEntitiesTC
(
CubicWebTC
):
def
test_title
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
for
etype
in
(
'SEDAArchiveUnit'
,
'SEDABinaryDataObject'
,
'SEDAPhysicalDataObject'
):
ent
=
cnx
.
create_entity
(
etype
,
user_annotation
=
u
'bla bla
\n
bli bli blo
\n
'
)
self
.
assertEqual
(
ent
.
dc_title
(),
u
'bla bla'
)
def
test_climb_rule_holders
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
unit
,
_
,
unit_alt_seq
=
create_archive_unit
(
transfer
)
subunit
,
_
,
subunit_alt_seq
=
create_archive_unit
(
unit_alt_seq
)
...
...
test/test_hooks.py
View file @
71f04ef3
...
...
@@ -27,7 +27,7 @@ class ValidationHooksTC(CubicWebTC):
assertValidationError
=
testutils
.
assertValidationError
def
test_ref_non_rule_constraints
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
access_scheme
=
create
(
'ConceptScheme'
,
title
=
u
'access'
)
...
...
@@ -61,7 +61,7 @@ class ValidationHooksTC(CubicWebTC):
def
test_empty_choice_created
(
self
):
"""Check that a ValidationError is raised when an empty SEDAAlt... entity is created."""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
# Create an empty SEDAAltAccessRulePreventInheritance
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
access_rule
=
cnx
.
create_entity
(
'SEDAAccessRule'
,
seda_access_rule
=
transfer
)
...
...
@@ -73,7 +73,7 @@ class ValidationHooksTC(CubicWebTC):
def
test_valid_choice_created
(
self
):
"""Check that everything goes fine when a valid SEDAAlt... entity is created."""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
# Create an empty SEDAArchiveUnit
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
access_rule
=
cnx
.
create_entity
(
'SEDAAccessRule'
,
seda_access_rule
=
transfer
)
...
...
@@ -87,7 +87,7 @@ class ValidationHooksTC(CubicWebTC):
"""Check that a ValidationError is raised when the last relation from a SEDAAlt... entity
is deleted.
"""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
# Create a valid SEDAAltAccessRulePreventInheritance
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
access_rule
=
cnx
.
create_entity
(
'SEDAAccessRule'
,
seda_access_rule
=
transfer
)
...
...
@@ -107,7 +107,7 @@ class ValidationHooksTC(CubicWebTC):
"""Check that everything goes fine when the a relation from a SEDAAlt... entity
is deleted but another relation remains.
"""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
# Create a valid SEDAAltAccessRulePreventInheritance with two items
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
access_rule
=
cnx
.
create_entity
(
'SEDAAccessRule'
,
seda_access_rule
=
transfer
)
...
...
@@ -126,7 +126,7 @@ class ValidationHooksTC(CubicWebTC):
class
SetDefaultHooksTC
(
CubicWebTC
):
def
test_default_code_list_version
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
for
rtype
,
etype
in
chain
(
zip
((
'seda_format_id_to'
,
'seda_mime_type_to'
,
'seda_encoding_to'
),
repeat
(
None
)),
...
...
@@ -152,7 +152,7 @@ class SetDefaultHooksTC(CubicWebTC):
should always be 1 (by default any card is allowed since in may be used in the context of
'main' reference).
"""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
transfer
)
version_of
=
cnx
.
create_entity
(
'SEDAIsVersionOf'
,
seda_is_version_of
=
unit_alt_seq
)
...
...
@@ -168,7 +168,7 @@ class SetDefaultHooksTC(CubicWebTC):
specifies user_cardinality for it, not for it's associated reference whose cardinality
should have the same value.
"""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
,
simplified_profile
=
True
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
transfer
)
...
...
@@ -191,7 +191,7 @@ class CheckProfileTC(CubicWebTC):
assertValidationError
=
testutils
.
assertValidationError
def
test_base
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
transfer
)
access_rule
=
cnx
.
create_entity
(
'SEDAAccessRule'
,
seda_access_rule
=
unit_alt_seq
)
...
...
test/test_html_generation.py
View file @
71f04ef3
...
...
@@ -32,7 +32,7 @@ class SEDAHTMLExportFuncTC(SEDAExportFuncTCMixIn, XmlTestMixin, CubicWebTC):
def
setup_database
(
self
):
super
(
SEDAHTMLExportFuncTC
,
self
).
setup_database
()
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
scheme
=
cnx
.
find
(
'ConceptScheme'
,
title
=
u
'Keyword Types'
).
one
()
some_concept
=
scheme
.
reverse_in_scheme
[
0
]
lang_rtype
=
cnx
.
find
(
'CWRType'
,
name
=
'seda_language_to'
).
one
()
...
...
@@ -67,7 +67,7 @@ class SEDAHTMLExportFuncTC(SEDAExportFuncTCMixIn, XmlTestMixin, CubicWebTC):
return
el_defs
def
test_profile1
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
entity_from_eid
(
self
.
transfer_eid
)
some_concept
=
cnx
.
entity_from_eid
(
self
.
concept_eid
)
profile
=
self
.
profile_etree
(
transfer
)
...
...
test/test_profile_generation.py
View file @
71f04ef3
...
...
@@ -222,7 +222,7 @@ class PathTargetValuesTC(CubicWebTC):
def
test_keyword_path
(
self
):
element_defs
=
iter
(
XSDMMapping
(
'Keyword'
))
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
kw
=
create
(
'SEDAKeyword'
,
user_cardinality
=
u
'0..n'
)
kt
=
create
(
'SEDAKeywordType'
,
seda_keyword_type_from
=
kw
)
...
...
@@ -283,7 +283,7 @@ class PathTargetValuesTC(CubicWebTC):
def
test_internal_reference
(
self
):
element_defs
=
iter
(
XSDMMapping
(
'DataObjectReference'
))
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
transfer
=
create
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
...
...
@@ -315,7 +315,7 @@ class PathTargetValuesTC(CubicWebTC):
class
SEDA2RNGExportTC
(
RelaxNGTestMixin
,
CubicWebTC
):
def
test_skipped_mandatory_simple
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
profile
=
self
.
profile_etree
(
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
))
date
=
self
.
get_element
(
profile
,
'Date'
)
...
...
@@ -336,7 +336,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
{
'name'
:
'schemeVersionID'
,
'use'
:
'optional'
,
'type'
:
'xsd:token'
}])
def
test_skipped_mandatory_complex
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
testutils
.
create_data_object
(
transfer
,
filename
=
u
'fixed.txt'
)
profile
=
self
.
profile_etree
(
transfer
)
...
...
@@ -355,7 +355,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
'type'
:
'xsd:anyURI'
}])
def
test_fileinfo_card
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
bdo
=
cnx
.
create_entity
(
'SEDABinaryDataObject'
,
user_annotation
=
u
'I am mandatory'
,
...
...
@@ -379,7 +379,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertElementDefinition
(
fileinfo
,
{
'name'
:
'FileInfo'
})
def
test_data_object_package_card
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
bdo
=
cnx
.
create_entity
(
'SEDABinaryDataObject'
,
user_annotation
=
u
'I am mandatory'
,
...
...
@@ -395,7 +395,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertElementDefinition
(
dop
,
{
'name'
:
'DataObjectPackage'
})
def
test_object_package_group
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
bdo
=
cnx
.
create_entity
(
'SEDABinaryDataObject'
,
user_annotation
=
u
'I am number one'
,
...
...
@@ -419,7 +419,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertEqual
(
len
(
self
.
xpath
(
dop
,
'./rng:group/*'
)),
3
)
def
test_transfer_annotation
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
profile
=
self
.
profile_etree
(
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
,
user_annotation
=
u
'some description'
))
...
...
@@ -428,7 +428,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertEqual
(
docs
[
0
].
text
,
'some description'
)
def
test_transfer_signature
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
cnx
.
create_entity
(
'SEDASignature'
,
seda_signature
=
transfer
)
profile
=
self
.
profile_etree
(
transfer
)
...
...
@@ -438,7 +438,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertOpenTypeIsDefined
(
profile
)
def
test_keyword
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
scheme
=
testutils
.
scheme_for_rtype
(
cnx
,
'seda_keyword_type_to'
,
u
'theme'
)
...
...
@@ -501,7 +501,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
[{
'name'
:
'schemeURI'
,
'fixed'
:
scheme
.
cwuri
}])
def
test_code_list
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
scheme
=
cnx
.
create_entity
(
'ConceptScheme'
,
title
=
u
'Keyword Types'
)
cnx
.
create_entity
(
'SEDAMimeTypeCodeListVersion'
,
...
...
@@ -526,7 +526,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
{
'name'
:
'listVersionID'
,
'use'
:
'optional'
,
'type'
:
'xsd:token'
}])
def
test_seda2_concept
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
scheme
=
create
(
'ConceptScheme'
,
title
=
u
'Digest algorithm'
)
some_concept
=
scheme
.
add_concept
(
label
=
u
'md5 algorithm'
,
language_code
=
u
'en'
)
...
...
@@ -562,7 +562,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
self
.
assertEqual
(
len
(
open_types
),
1
)
def
test_data_duplicates
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
transfer
,
user_cardinality
=
u
'0..n'
)
...
...
@@ -575,7 +575,7 @@ class SEDAExportFuncTCMixIn(object):
"""Test that SEDA profile export works correctly."""
def
setup_database
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
scheme
=
create
(
'ConceptScheme'
,
title
=
u
'Keyword Types'
)
# ensure we're able to export concept with unexpected language code
...
...
@@ -644,7 +644,7 @@ class SEDAExportFuncTCMixIn(object):
def
test_profile1
(
self
):
"""Check a minimal SEDA profile validating BV2.0_min.xml."""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
mda_scheme
=
cnx
.
find
(
'ConceptScheme'
,
title
=
u
'Keyword Types'
).
one
()
transfer
=
cnx
.
entity_from_eid
(
self
.
transfer_eid
)
root
=
self
.
profile_etree
(
transfer
)
...
...
@@ -689,7 +689,7 @@ class SEDARNGExportFuncTC(SEDAExportFuncTCMixIn, RelaxNGTestMixin, CubicWebTC):
class
OldSEDAExportMixin
(
object
):
def
setup_database
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
concepts
=
{}
...
...
@@ -808,7 +808,7 @@ class OldSEDAExportMixin(object):
self
.
agent_eid
=
agent
.
eid
def
_test_profile
(
self
,
adapter_id
,
expected_file
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
entity_from_eid
(
self
.
transfer_eid
)
file_concept
=
cnx
.
entity_from_eid
(
self
.
file_concept_eid
)
agent
=
cnx
.
entity_from_eid
(
self
.
agent_eid
)
...
...
@@ -868,7 +868,7 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
def
test_seda_0_2_bordereau_ref
(
self
):
"""Check a sample SEDA 0.2 profile validation."""
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
transfer
=
create
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
,
...
...
test/test_schema.py
View file @
71f04ef3
...
...
@@ -28,7 +28,7 @@ class SchemaConceptConstraintsTC(CubicWebTC):
assertValidationError
=
testutils
.
assertValidationError
def
setup_database
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
mt_scheme
=
testutils
.
scheme_for_type
(
cnx
,
'seda_mime_type_to'
,
None
)
mt_concept
=
mt_scheme
.
add_concept
(
label
=
u
'text/plain'
)
enc_scheme
=
testutils
.
scheme_for_type
(
cnx
,
'seda_encoding_to'
,
None
)
...
...
@@ -40,7 +40,7 @@ class SchemaConceptConstraintsTC(CubicWebTC):
self
.
enc_concept
=
enc_concept
.
eid
def
test_code_lists_constraints_simple
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
bdo
=
testutils
.
create_transfer_to_bdo
(
cnx
)
transfer
=
bdo
.
container
[
0
]
cnx
.
create_entity
(
'SEDAMessageDigestAlgorithmCodeListVersion'
,
...
...
@@ -70,13 +70,13 @@ class SchemaConceptConstraintsTC(CubicWebTC):
cnx
.
commit
()
def
test_archive_transfer_mime_type_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
bdo
=
testutils
.
create_transfer_to_bdo
(
cnx
)
cnx
.
commit
()
# will setup code list version
self
.
assertMimeTypeConcept
(
bdo
)
def
test_component_archive_unit_mime_type_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
bdo
=
testutils
.
create_data_object
(
unit_alt_seq
)
cnx
.
commit
()
...
...
@@ -97,13 +97,13 @@ class SchemaConceptConstraintsTC(CubicWebTC):
cnx
.
commit
()
def
test_archive_transfer_encoding_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
bdo
=
testutils
.
create_transfer_to_bdo
(
cnx
)
cnx
.
commit
()
# will setup code list version
self
.
assertEncodingConcept
(
bdo
)
def
test_component_archive_unit_encoding_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
bdo
=
testutils
.
create_data_object
(
unit_alt_seq
)
cnx
.
commit
()
...
...
@@ -120,7 +120,7 @@ class SchemaConceptConstraintsTC(CubicWebTC):
cnx
.
commit
()
def
test_archive_transfer_digest_algorithm_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
bdo
=
testutils
.
create_transfer_to_bdo
(
cnx
)
cnx
.
commit
()
# commit first to get the container
transfer
=
bdo
.
container
[
0
]
...
...
@@ -131,7 +131,7 @@ class SchemaConceptConstraintsTC(CubicWebTC):
self
.
assertDigestAlgorithmConcept
(
bdo
)
def
test_component_archive_unit_digest_algorithm_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
bdo
=
testutils
.
create_data_object
(
unit_alt_seq
)
bdo_type
=
cnx
.
find
(
'CWEType'
,
name
=
u
'SEDABinaryDataObject'
).
one
()
...
...
@@ -147,7 +147,7 @@ class SchemaTC(CubicWebTC):
assertValidationError
=
testutils
.
assertValidationError
def
test_component_archive_unit_rule_constraint
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
for
rule_type
in
(
'access'
,
'appraisal'
):
etype
=
'SEDASeq{0}RuleRule'
.
format
(
rule_type
.
capitalize
())
scheme
=
testutils
.
scheme_for_type
(
cnx
,
'seda_rule'
,
etype
)
...
...
@@ -206,7 +206,7 @@ class SchemaTC(CubicWebTC):
'G name IN("managers", "users")'
)
def
test_rule_default_cardinality
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'test profile'
)
for
rule_type
in
(
'access'
,
'appraisal'
):
rule_etype
=
'SEDA{0}Rule'
.
format
(
rule_type
.
capitalize
())
...
...
@@ -222,7 +222,7 @@ class SchemaTC(CubicWebTC):
def
test_fti
(
self
):
# "Reverse" text to be searched in order not to be troubled by other
# entities that may live in the DB (e.g. Concepts) with similar text.
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'Profile'
)
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
transfer
,
title
=
u
'transfer name'
[::
-
1
])
...
...
@@ -238,7 +238,7 @@ class SchemaTC(CubicWebTC):
self
.
assertEqual
([
r
for
r
,
in
rset
.
rows
],
[
transfer
.
eid
])
def
test_scheme_code_keyword_type_constraint
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
ckt_scheme
=
testutils
.
scheme_for_type
(
cnx
,
'seda_keyword_type_to'
,
None
)
ckt_concept
=
ckt_scheme
.
add_concept
(
label
=
u
'geoname'
)
scheme
=
testutils
.
scheme_for_type
(
cnx
,
'seda_mime_type_to'
,
None
)
...
...
@@ -273,10 +273,10 @@ class SecurityTC(CubicWebTC):
cnx
.
commit
()
def
test_profile
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
self
.
create_user
(
cnx
,
login
=
'bob'
)
cnx
.
commit
()
with
self
.
new_access
(
'alice'
).
repo_
cnx
()
as
cnx
:
with
self
.
new_access
(
'alice'
).
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'Alice Profile'
)
testutils
.
create_archive_unit
(
transfer
)
testutils
.
create_authority_record
(
cnx
,
u
'Archival inc.'
,
...
...
@@ -288,7 +288,7 @@ class SecurityTC(CubicWebTC):
seda_mime_type_code_list_version_from
=
transfer
,
seda_mime_type_code_list_version_to
=
scheme
)
cnx
.
commit
()
with
self
.
new_access
(
'bob'
).
repo_
cnx
()
as
cnx
:
with
self
.
new_access
(
'bob'
).
cnx
()
as
cnx
:
transfer
=
cnx
.
entity_from_eid
(
transfer
.
eid
)
# modification of the container
with
self
.
assertUnauthorized
(
cnx
):
...
...
@@ -323,7 +323,7 @@ class SecurityTC(CubicWebTC):
transfer
.
cw_delete
()
def
test_archive_unit
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
cnx
.
commit
()
...
...
@@ -332,7 +332,7 @@ class SecurityTC(CubicWebTC):
unit_alt_seq
.
reverse_seda_title
[
0
].
cw_set
(
title
=
u
'gloup'
)
cnx
.
commit
()
with
self
.
new_access
(
'anon'
).
client_
cnx
()
as
cnx
:
with
self
.
new_access
(
'anon'
).
cnx
()
as
cnx
:
title
=
cnx
.
entity_from_eid
(
unit_alt_seq
.
reverse_seda_title
[
0
].
eid
)
unit
=
cnx
.
entity_from_eid
(
unit
.
eid
)
with
self
.
assertUnauthorized
(
cnx
):
...
...
@@ -345,7 +345,7 @@ class SecurityTC(CubicWebTC):
title
.
cw_delete
()
with
self
.
assertUnauthorized
(
cnx
):
unit
.
cw_delete
()
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
=
cnx
.
entity_from_eid
(
unit
.
eid
)
unit
.
cw_delete
()
cnx
.
commit
()
...
...
@@ -357,11 +357,11 @@ class SecurityTC(CubicWebTC):
def
test_users_can_clone
(
self
):
"""Functional test for SEDA component clone."""
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
cnx
.
commit
()
with
self
.
new_access
(
'alice'
).
repo_
cnx
()
as
cnx
:
with
self
.
new_access
(
'alice'
).
cnx
()
as
cnx
:
unit
=
cnx
.
entity_from_eid
(
unit
.
eid
)
cloned
=
cnx
.
create_entity
(
unit
.
cw_etype
,
user_annotation
=
u
'x'
,
clone_of
=
unit
)
cnx
.
commit
()
...
...
test/test_views.py
View file @
71f04ef3
...
...
@@ -36,7 +36,7 @@ def entity_fields(fields):
class
ManagementRulesTC
(
CubicWebTC
):
def
test_rule_ref_vocabulary
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
create
=
cnx
.
create_entity
access_scheme
=
create
(
'ConceptScheme'
,
title
=
u
'access'
)
...
...
@@ -72,7 +72,7 @@ class ManagementRulesTC(CubicWebTC):
(
access_concept
.
label
(),
text_type
(
access_concept
.
eid
))])
def
test_archive_unit_component_rule_ref_vocabulary
(
self
):
with
self
.
admin_access
.
client_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
unit
,
unit_alt
,
unit_alt_seq
=
testutils
.
create_archive_unit
(
None
,
cnx
=
cnx
)
for
rule_type
in
(
'access'
,
'appraisal'
):
etype
=
'SEDASeq{0}RuleRule'
.
format
(
rule_type
.
capitalize
())
...
...
@@ -94,7 +94,7 @@ class PermissionsTC(CubicWebTC):
"""Check that a user cannot edit a SEDA profile he/she did not create."""
alice_login
=
'alice'
bob_login
=
'bob'
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
self
.
create_user
(
cnx
,
login
=
alice_login
)
self
.
create_user
(
cnx
,
login
=
bob_login
)
cnx
.
commit
()
...
...
@@ -123,7 +123,7 @@ class RelationWidgetTC(CubicWebTC):
"""Functional test case about the relation widget."""
def
test_linkable_rset
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'Test widget'
)
bdo
=
cnx
.
create_entity
(
'SEDABinaryDataObject'
,
user_annotation
=
u
'I am mandatory'
,
...
...
@@ -140,7 +140,7 @@ class RelationWidgetTC(CubicWebTC):
view
=
self
.
vreg
[
'views'
].
select
(
'search_related_entities'
,
req
,
rset
=
compressed
.
as_rset
())
self
.
failIf
(
view
.
linkable_rset
())
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
scheme
=
cnx
.
create_entity
(
'ConceptScheme'
,
title
=
u
'CompressionAlgorithm'
)
scheme
.
add_concept
(
label
=
u
'bz2'
)
cnx
.
create_entity
(
'SEDACompressionAlgorithmCodeListVersion'
,
...
...
@@ -296,7 +296,7 @@ class SimplifiedFormsTC(CubicWebTC):
"""Functional test case about forms in the web interface."""
def
setup_database
(
self
):
with
self
.
admin_access
.
repo_
cnx
()
as
cnx
:
with
self
.
admin_access
.
cnx
()
as
cnx
:
transfer
=
cnx
.
create_entity
(
'SEDAArchiveTransfer'
,
title
=
u
'diagnosis testing'
,
simplified_profile
=
True
)
archive_unit
=
testutils
.
create_archive_unit
(
transfer
)[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment