Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pycomsdk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com
pycomsdk
Commits
cc6402f6
Commit
cc6402f6
authored
3 weeks ago
by
Sergey Bobrov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit тест графа c подграфами проведен и отлажен
parent
657280ca
master
dev
dev_parser_aDOT
1 merge request
!4
Dev parser a dot
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
5 deletions
+91
-5
simplest.py
test_funcs/simplest.py
+23
-0
main_graph.adot
tests/test_aDOT/test_adot_files/main_graph.adot
+21
-0
postprocess.adot
tests/test_aDOT/test_adot_files/postprocess.adot
+17
-0
preprocess.adot
tests/test_aDOT/test_adot_files/preprocess.adot
+18
-0
unit_test_aDOT.py
tests/test_aDOT/unit_test_aDOT.py
+12
-5
No files found.
test_funcs/simplest.py
View file @
cc6402f6
...
@@ -64,4 +64,27 @@ def branch_selector(data):
...
@@ -64,4 +64,27 @@ def branch_selector(data):
condition
=
check_condition
(
data
)
condition
=
check_condition
(
data
)
return
[
condition
,
not
condition
]
return
[
condition
,
not
condition
]
def
init_data
(
data
):
data
[
'initialized'
]
=
True
data
[
'processed'
]
=
False
data
[
'value'
]
=
data
.
get
(
'input'
,
0
)
def
validate_data
(
data
):
if
'value'
not
in
data
:
raise
ValueError
(
"Data not initialized"
)
data
[
'valid'
]
=
True
def
process_data
(
data
):
if
not
data
.
get
(
'valid'
,
False
):
raise
ValueError
(
"Invalid data"
)
data
[
'processed'
]
=
True
data
[
'value'
]
*=
2
def
save_result
(
data
):
data
[
'saved'
]
=
True
data
[
'result'
]
=
data
[
'value'
]
def
cleanup
(
data
):
data
[
'clean'
]
=
True
This diff is collapsed.
Click to expand it.
tests/test_aDOT/test_adot_files/main_graph.adot
0 → 100644
View file @
cc6402f6
digraph MAIN_GRAPH {
// Функции
MAIN_PROCESS [module=test_funcs.simplest, entry_func=process_data]
/ Функции-предикаты
ALWAYS_TRUE [module=test_funcs.simplest, entry_func=true_predicate, comment = pred_ALWAYS_TRUE]
// Морфизмы
EDGE_MAIN [predicate=ALWAYS_TRUE, function=MAIN_PROCESS, comment = edge_1]
// Главный граф
PREPROCESS [subgraph=./test_adot_files/preprocess.adot]
POSTPROCESS [subgraph=./test_adot_files/postprocess.adot]
__BEGIN__ -> PREPROCESS
PREPROCESS -> MAIN_PROCESS [morphism=EDGE_MAIN]
MAIN_PROCESS -> POSTPROCESS
POSTPROCESS -> __END__
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_aDOT/test_adot_files/postprocess.adot
0 → 100644
View file @
cc6402f6
digraph POSTPROCESS {
// Функции постобработки
SAVE_RESULT [module=test_funcs.simplest, entry_func=save_result]
CLEANUP [module=test_funcs.simplest, entry_func=cleanup]
/ Функции-предикаты
ALWAYS_TRUE [module=test_funcs.simplest, entry_func=true_predicate, comment = pred_ALWAYS_TRUE_postprocess]
// Морфизмы
EDGE_1 [predicate=ALWAYS_TRUE, function=SAVE_RESULT, comment = edge_1_postprocess]
EDGE_2 [predicate=ALWAYS_TRUE, function=CLEANUP, comment = edge_2_postprocess]
__BEGIN__ -> SAVE
SAVE -> FINAL [morphism=EDGE_1]
FINAL -> __END__ [morphism=EDGE_2]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_aDOT/test_adot_files/preprocess.adot
0 → 100644
View file @
cc6402f6
digraph PREPROCESS {
// Функции предобработки
INIT_DATA [module=test_funcs.simplest, entry_func=init_data, comment=""]
VALIDATE [module=test_funcs.simplest, entry_func=validate_data]
/ Функции-предикаты
ALWAYS_TRUE [module=test_funcs.simplest, entry_func=true_predicate, comment = pred_ALWAYS_TRUE]
// Морфизмы
EDGE_1 [predicate=ALWAYS_TRUE, function=INIT_DATA, comment = edge_1]
EDGE_2 [predicate=ALWAYS_TRUE, function=VALIDATE, comment = edge_2]
__BEGIN__ -> INIT
INIT -> VALIDATE [morphism=EDGE_1]
VALIDATE -> __END__ [morphism=EDGE_2]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_aDOT/unit_test_aDOT.py
View file @
cc6402f6
...
@@ -38,7 +38,7 @@ class TestADOTParser(unittest.TestCase):
...
@@ -38,7 +38,7 @@ class TestADOTParser(unittest.TestCase):
"Граф должен уменьшать a до 0"
)
"Граф должен уменьшать a до 0"
)
# Дополнительная проверка с другим начальным значением
# Дополнительная проверка с другим начальным значением
data
=
{
"a"
:
3
}
data
=
{
"a"
:
10
}
result
=
graph
.
run
(
data
)
result
=
graph
.
run
(
data
)
self
.
assertTrue
(
result
)
self
.
assertTrue
(
result
)
self
.
assertEqual
(
data
[
"a"
],
0
)
self
.
assertEqual
(
data
[
"a"
],
0
)
...
@@ -62,14 +62,21 @@ class TestADOTParser(unittest.TestCase):
...
@@ -62,14 +62,21 @@ class TestADOTParser(unittest.TestCase):
def
test_subgraph_integration
(
self
):
def
test_subgraph_integration
(
self
):
"""Тест интеграции подграфов"""
"""Тест интеграции подграфов"""
graph
=
self
.
parser
.
parse_file
(
os
.
path
.
join
(
self
.
test_files_dir
,
"
sub
graph.adot"
))
graph
=
self
.
parser
.
parse_file
(
os
.
path
.
join
(
self
.
test_files_dir
,
"
main_
graph.adot"
))
self
.
assertIsInstance
(
graph
,
Graph
)
self
.
assertIsInstance
(
graph
,
Graph
)
data
=
{}
data
=
{
'input'
:
5
}
result
=
graph
.
run
(
data
)
result
=
graph
.
run
(
data
)
print
(
data
)
self
.
assertTrue
(
result
)
self
.
assertTrue
(
result
)
self
.
assertTrue
(
data
[
"preprocessed"
])
self
.
assertEqual
(
data
[
'value'
],
10
)
# 5 * 2 = 10
self
.
assertTrue
(
data
[
"postprocessed"
])
self
.
assertTrue
(
data
[
'initialized'
])
self
.
assertTrue
(
data
[
'valid'
])
self
.
assertTrue
(
data
[
'processed'
])
self
.
assertTrue
(
data
[
'saved'
])
self
.
assertTrue
(
data
[
'clean'
])
self
.
assertEqual
(
data
[
'result'
],
10
)
def
test_edge_types
(
self
):
def
test_edge_types
(
self
):
"""Тест разных типов ребер (-> и =>)"""
"""Тест разных типов ребер (-> и =>)"""
...
...
This diff is collapsed.
Click to expand it.
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