Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
mentat-test
Commits
710f35d5
Commit
710f35d5
authored
2 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Add internal structure for detectors. (Redmine issue:
#7577
)
parent
b036337b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/mentat/datatype/internal.py
+45
-0
45 additions, 0 deletions
lib/mentat/datatype/internal.py
lib/mentat/datatype/test_internal.py
+22
-0
22 additions, 0 deletions
lib/mentat/datatype/test_internal.py
with
67 additions
and
0 deletions
lib/mentat/datatype/internal.py
+
45
−
0
View file @
710f35d5
...
@@ -949,6 +949,51 @@ class EventStat(typedcols.TypedDict):
...
@@ -949,6 +949,51 @@ class EventStat(typedcols.TypedDict):
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def
typedef_detector
(
flavour
,
list_flavour
,
addon
=
None
):
"""
Typedef generator for detector records.
"""
tdef
=
{
'
_id
'
:
{
'
type
'
:
flavour
[
'
String
'
],
'
required
'
:
True
},
'
ts
'
:
{
'
type
'
:
flavour
[
'
Datetime
'
],
'
required
'
:
True
,
'
default
'
:
time
.
time
},
'
name
'
:
{
'
type
'
:
flavour
[
'
String
'
],
'
required
'
:
True
},
'
source
'
:
{
'
type
'
:
flavour
[
'
String
'
],
'
required
'
:
True
},
'
description
'
:
{
'
type
'
:
flavour
[
'
String
'
]
},
'
credibility
'
:
{
'
type
'
:
flavour
[
'
Float
'
],
'
required
'
:
True
}
}
if
addon
is
not
None
:
tdef
.
update
(
addon
)
return
tdef
class
Detector
(
typedcols
.
TypedDict
):
"""
Implementation of detector structure.
"""
allow_unknown
=
True
typedef
=
typedef_detector
(
types_internal
,
types_internal_list
)
#-------------------------------------------------------------------------------
def
typedef_report
(
flavour
,
list_flavour
,
addon
=
None
):
def
typedef_report
(
flavour
,
list_flavour
,
addon
=
None
):
"""
"""
Typedef generator for report records.
Typedef generator for report records.
...
...
This diff is collapsed.
Click to expand it.
lib/mentat/datatype/test_internal.py
+
22
−
0
View file @
710f35d5
...
@@ -212,6 +212,14 @@ class TestMentatDatatypeInternal(unittest.TestCase):
...
@@ -212,6 +212,14 @@ class TestMentatDatatypeInternal(unittest.TestCase):
"
name
"
:
"
Jan Mach
"
"
name
"
:
"
Jan Mach
"
}
}
detector_raw
=
{
"
_id
"
:
"
1
"
,
"
ts
"
:
1388577600
,
"
source
"
:
"
warden
"
,
"
credibility
"
:
0.73
,
"
name
"
:
"
Test detector
"
}
def
setUp
(
self
):
def
setUp
(
self
):
pass
pass
...
@@ -306,6 +314,20 @@ class TestMentatDatatypeInternal(unittest.TestCase):
...
@@ -306,6 +314,20 @@ class TestMentatDatatypeInternal(unittest.TestCase):
if
self
.
verbose
:
if
self
.
verbose
:
pprint
(
uac
)
pprint
(
uac
)
def
test_05_detector
(
self
):
"""
Perform tests of parsing detectors.
"""
self
.
maxDiff
=
None
det
=
mentat
.
datatype
.
internal
.
Detector
(
self
.
detector_raw
)
self
.
assertEqual
(
det
[
'
_id
'
],
'
1
'
)
self
.
assertEqual
(
det
[
'
credibility
'
],
0.73
)
self
.
assertEqual
(
det
[
'
name
'
],
'
Test detector
'
)
self
.
assertEqual
(
det
[
'
source
'
],
'
warden
'
)
if
self
.
verbose
:
pprint
(
det
)
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
...
...
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