Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-octaveinttest
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-octaveinttest
Commits
0a028c41
Commit
0a028c41
authored
Aug 31, 2021
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
Reenabled tests.
parent
0ea023fa
No related branches found
No related tags found
1 merge request
!3
ENH: Full functionality
Pipeline
#12836
failed
Aug 31, 2021
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/Run_Test.m
+1
-1
1 addition, 1 deletion
test/Run_Test.m
test/test_query_retrieve.m
+3
-3
3 additions, 3 deletions
test/test_query_retrieve.m
test/test_transaction.m
+40
-86
40 additions, 86 deletions
test/test_transaction.m
with
44 additions
and
90 deletions
test/Run_Test.m
+
1
−
1
View file @
0a028c41
...
@@ -20,7 +20,7 @@ pkg load caosdb;
...
@@ -20,7 +20,7 @@ pkg load caosdb;
all_tests
=
true
;
all_tests
=
true
;
all_tests
&=
moxunit_runtests
(
"-verbose"
,
"test_query_retrieve.m"
);
all_tests
&=
moxunit_runtests
(
"-verbose"
,
"test_query_retrieve.m"
);
%
all_tests &= moxunit_runtests("-verbose", "test_transaction.m");
all_tests
&=
moxunit_runtests
(
"-verbose"
,
"test_transaction.m"
);
if
not
(
all_tests
)
if
not
(
all_tests
)
exit
(
1
);
exit
(
1
);
...
...
This diff is collapsed.
Click to expand it.
test/test_query_retrieve.m
+
3
−
3
View file @
0a028c41
...
@@ -138,7 +138,7 @@ function test_retrieve_multiple()
...
@@ -138,7 +138,7 @@ function test_retrieve_multiple()
end
end
%% Test query execution
%% Test query execution
function
__
test_execute_query
()
function
test_execute_query
()
c
=
Caosdb
();
c
=
Caosdb
();
% FIND query
% FIND query
query
=
[
'FIND Record Violin WITH name="Sherlock Holmes'
"'"
' violin"'
];
query
=
[
'FIND Record Violin WITH name="Sherlock Holmes'
"'"
' violin"'
];
...
@@ -163,7 +163,7 @@ end
...
@@ -163,7 +163,7 @@ end
% Error handling tests %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Error handling tests %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test retrieval with errors
%% Test retrieval with errors
function
_
test_retrieve_failure
()
function
test_retrieve_failure
()
% Default connection configuration is sufficient.
% Default connection configuration is sufficient.
c
=
Caosdb
();
c
=
Caosdb
();
...
@@ -179,7 +179,7 @@ function _test_retrieve_failure()
...
@@ -179,7 +179,7 @@ function _test_retrieve_failure()
end
end
%% Test querying with errors
%% Test querying with errors
function
_
test_execute_query_failure
()
function
test_execute_query_failure
()
c
=
Caosdb
();
c
=
Caosdb
();
results
=
c
.
query
(
"FIND Record I-Do-Not-Exist"
);
% Must not segfault.
results
=
c
.
query
(
"FIND Record I-Do-Not-Exist"
);
% Must not segfault.
assertTrue
(
isempty
(
results
));
assertTrue
(
isempty
(
results
));
...
...
This diff is collapsed.
Click to expand it.
test/test_transaction.m
+
40
−
86
View file @
0a028c41
...
@@ -156,106 +156,60 @@ function test_insert_entity()
...
@@ -156,106 +156,60 @@ function test_insert_entity()
compare_parents
(
retrieved
.
get_parents
{
1
},
par
,
{
"name"
});
compare_parents
(
retrieved
.
get_parents
{
1
},
par
,
{
"name"
});
% Check errors
% Check errors
assertFalse
(
inserted
.
has_errors
());
assertFalse
(
inserted
.
has_errors
(),
print_messages
(
inserted
.
get_errors
(),
"error"
));
assertFalse
(
inserted
.
has_warnings
());
assertFalse
(
inserted
.
has_warnings
(),
print_messages
(
inserted
.
get_warnings
(),
"warning"
));
assertFalse
(
inserted
.
has_infos
());
assertFalse
(
inserted
.
has_infos
(),
print_messages
(
inserted
.
get_infos
(),
"info"
));
assertFalse
(
retrieved
.
has_errors
());
assertFalse
(
retrieved
.
has_errors
(),
print_messages
(
retrieved
.
get_errors
(),
"error"
));
assertFalse
(
retrieved
.
has_warnings
());
assertFalse
(
retrieved
.
has_warnings
(),
print_messages
(
retrieved
.
get_warnings
(),
"warning"
));
assertFalse
(
retrieved
.
has_infos
());
assertFalse
(
retrieved
.
has_infos
(),
print_messages
(
retrieved
.
get_infos
(),
"info"
));
cleanup
();
end
end
%% Test updating of Entities
%% Test updating of Entities
function
x
test_update_entity
()
function
test_update_entity
()
% Default connection configuration is sufficient.
% Default connection configuration is sufficient.
cleanup
();
cleanup
();
disp
(
"================ test_update_entity =============="
);
c
=
Caosdb
();
c
=
Caosdb
();
% Create & insert Properties first (TODO Insert in a single step)
% Create & insert Properties first (TODO Insert in a single step)
P1
=
Entity
();
P1
=
Entity
();
P1
.
role
=
"PROPERTY"
;
P1
.
role
=
"PROPERTY"
;
P1
.
name
=
"Prop 1"
;
P1
.
name
=
"Prop 1"
;
P1
.
set_datatype
(
"DOUBLE"
);
%% TODO(dh) units
% P1.unit = "Whales";
P2
=
Entity
();
P1
.
set_datatype
(
"INTEGER"
,
false
,
true
);
P2
.
role
=
"PROPERTY"
;
P1
.
value
=
int64
([
1
,
2
,
3
,
4
,
2
^
31
-
1
,
-
2
^
31
]);
P2
.
name
=
"Prop 2"
;
P2
.
set_datatype
(
"BOOLEAN"
);
P2
.
unit
=
"MegaTruths"
;
P1_id
=
c
.
insert
({
P1
}){
1
}
.
id
;
P1_id
=
c
.
insert
({
P1
}){
1
}
.
id
;
P2_id
=
c
.
insert
({
P2
}){
1
}
.
id
;
% disp(P1)
return
P1_upd
=
c
.
retrieve_by_id
(
P1_id
){
1
};
% set plain Octave properties, reuse IDs
% disp(P1_upd);
p1
=
Property
();
P1_upd
.
name
=
"Prop 1a"
;
p1
.
id
=
P1_id
;
P1_upd
.
description
=
"This is a described Property."
;
p1
.
name
=
P1
.
name
;
P1_upd
.
set_datatype
(
"DOUBLE"
,
false
,
false
);
% Double scalar
p1
.
description
=
""
;
%% TODO(dh) units
p1
.
importance
=
"SUGGESTED"
;
% P1_upd.unit = "Wales"
p1
.
set_datatype
(
"DOUBLE"
);
P1_upd
.
value
=
1e-300
;
p1
.
unit
=
"Mt"
;
% p1.value = 0;
P1_upd_result
=
c
.
update
({
P1_upd
}){
1
};
p2
=
Property
();
assertFalse
(
P1_upd_result
.
has_errors
(),
print_messages
(
P1_upd_result
.
get_errors
(),
"error"
));
p2
.
id
=
P2_id
;
% TODO(dh) unit warning is currently existing
p2
.
name
=
P2
.
name
;
% assertFalse(P1_upd_result.has_warnings(),
p2
.
description
=
"None"
;
% print_messages(P1_upd_result.get_warnings(), "warning"));
p2
.
importance
=
"SUGGESTED"
;
assertFalse
(
P1_upd_result
.
has_infos
(),
print_messages
(
P1_upd_result
.
get_infos
(),
"info"
));
p2
.
set_datatype
(
"BOOLEAN"
);
p2
.
value
=
logical
(
1
);
assertEqual
(
P1_upd_result
.
id
,
P1_id
);
retrieved
=
c
.
retrieve_by_id
(
P1_id
);
% Get ID of parent first
P1_upd_retr
=
retrieved
{
1
};
violin_id
=
c
.
query
(
"FIND RECORDTYPE Violin"
){
1
}
.
id
;
% disp(P1_upd_retr);
par
=
Parent
();
assertFalse
(
P1_upd_retr
.
has_errors
(),
print_messages
(
P1_upd_retr
.
get_errors
(),
"error"
));
par
.
id
=
violin_id
;
assertFalse
(
P1_upd_retr
.
has_warnings
(),
print_messages
(
P1_upd_retr
.
get_warnings
(),
"warning"
));
par
.
name
=
"Violin"
;
assertFalse
(
P1_upd_retr
.
has_infos
(),
print_messages
(
P1_upd_retr
.
get_infos
(),
"info"
));
par
.
description
=
"Some description"
;
compare_properties
(
P1_upd_retr
,
P1_upd
);
e
=
Entity
();
e
.
role
=
"RecordType"
;
e
.
name
=
"Test RecordType"
;
% merge objects
e
.
set_properties
({
p1
,
p2
});
% e.set_parents({par});
% There are 3 steps:
% 1. Insert
inserted
=
c
.
insert
({
e
});
% 2. Look at insertion result
assertEqual
(
numel
(
inserted
),
1
);
inserted
=
inserted
{
1
};
assertTrue
(
isinteger
(
int64
(
str2num
(
inserted
.
id
))));
assertFalse
(
isempty
(
inserted
.
id
));
% 3. Retrieve the inserted entity again, by ID
retrieved
=
c
.
retrieve_by_id
(
inserted
.
id
){
1
};
% Compare results
assertEqual
(
e
.
role
,
retrieved
.
role
);
assertEqual
(
e
.
name
,
retrieved
.
name
);
assertEqual
(
numel
(
e
.
get_properties
()),
numel
(
retrieved
.
get_properties
()));
props
=
retrieved
.
get_properties
();
prop_names
=
cellfun
(
@
(
x
)(
getfield
(
x
.
to_struct
(),
"name"
)),
props
,
"UniformOutput"
,
false
);
assertTrue
(
all
(
ismember
({
"Prop 1"
,
"Prop 2"
},
prop_names
)));
i_1
=
find
(
cellfun
(
@
(
x
)
isequal
(
x
,
"Prop 1"
),
prop_names
));
i_2
=
find
(
cellfun
(
@
(
x
)
isequal
(
x
,
"Prop 2"
),
prop_names
));
prop_1
=
props
{
i_1
};
prop_2
=
props
{
i_2
};
disp
(
"===================="
);
disp
(
p1
.
to_struct
);
disp
(
"...................."
);
disp
(
prop_1
.
to_struct
());
assertTrue
(
isequal
(
prop_1
.
to_struct
(),
p1
.
to_struct
()));
cleanup
();
assertTrue
(
isequal
(
prop_2
.
to_struct
(),
p2
.
to_struct
()));
assertTrue
(
isequal
(
retrieved
.
get_parents
{
1
}
.
to_struct
(),
par
.
to_struct
()));
% Check errors
assertFalse
(
inserted
.
has_errors
());
assertFalse
(
inserted
.
has_warnings
());
assertFalse
(
inserted
.
has_infos
());
assertFalse
(
retrieved
.
has_errors
());
assertFalse
(
retrieved
.
has_warnings
());
assertFalse
(
retrieved
.
has_infos
());
end
end
% Utility functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Utility functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
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