Skip to content
Snippets Groups Projects
Commit 2b28ee68 authored by Cornelia Michlits's avatar Cornelia Michlits
Browse files

#104 ontology - add tests for validator function

parent d42c66d9
No related branches found
No related tags found
4 merge requests!81New stable release,!43Merge dev to master,!33Draft: merge dev to master,!32Add units-service to dev
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment