Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
2b28ee68
Commit
2b28ee68
authored
3 years ago
by
Cornelia Michlits
Browse files
Options
Downloads
Patches
Plain Diff
#104 ontology - add tests for validator function
parent
d42c66d9
No related branches found
No related tags found
4 merge requests
!81
New stable release
,
!43
Merge dev to master
,
!33
Draft: merge dev to master
,
!32
Add units-service to dev
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fda-units-service/test/test_validator.py
+35
-0
35 additions, 0 deletions
fda-units-service/test/test_validator.py
with
35 additions
and
0 deletions
fda-units-service/test/test_validator.py
0 → 100644
+
35
−
0
View file @
2b28ee68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 5 19:41:04 2021
@author: Cornelia Michlits
"""
import
unittest
import
sys
sys
.
path
.
append
(
"
..
"
)
from
validate
import
validator
,
stringmapper
exp_out_True
=
"
{
'
valid
'
: True}
"
exp_out_False
=
"
{
'
valid
'
: False}
"
class
TestStringMethods
(
unittest
.
TestCase
):
#metre is SI Unit
def
test_validator_true
(
self
):
self
.
assertEqual
(
str
(
validator
(
'
metre
'
)),
exp_out_True
)
#diameter is measure, but no SI Unit
def
test_validator_no_SI_Unit
(
self
):
self
.
assertEqual
(
str
(
validator
(
'
diameter
'
)),
exp_out_False
)
#misspelling
def
test_validator_misspelling
(
self
):
self
.
assertEqual
(
str
(
validator
(
'
metreee
'
)),
exp_out_False
)
#Divided unit
def
test_validator_dividedunit
(
self
):
self
.
assertEqual
(
str
(
validator
(
stringmapper
(
'
mole per metre
'
))),
exp_out_True
)
#Prefixed unit
def
test_validator_prefixedunit
(
self
):
self
.
assertEqual
(
str
(
validator
(
stringmapper
(
'
zettamole
'
))),
exp_out_True
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Cornelia Michlits
@cornelia.michlits
mentioned in commit
77cdf4d3
·
3 years ago
mentioned in commit
77cdf4d3
mentioned in commit 77cdf4d3d412b1d1b866d590dc1274c343cfa5c1
Toggle commit list
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