Commit 9f6636aa authored by Gabriel Couture's avatar Gabriel Couture

Adding is_structure_name_is_allowed method

parent 07b2db5c
Pipeline #283 canceled with stages
......@@ -3,8 +3,7 @@ import subprocess
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
TG263_FLAKE8_COMMAND = ['./venv/bin/flake8', 'tg263']
TESTS_FLAKE8_COMMAND = ['./venv/bin/flake8', '--ignore=E501', 'tests']
FLAKE8_COMMAND = ['./venv/bin/flake8', '--ignore=E501', 'tg263', 'tests']
MYPY_COMMAND = ['./venv/bin/mypy', 'tg263']
TESTS_COMMAND = ['./venv/bin/python', '-m', 'unittest', 'discover', '-s', './tests/']
......@@ -31,8 +30,7 @@ class LintTests(TestCommand):
user_options = []
def run_tests(self):
_run_command(TG263_FLAKE8_COMMAND)
_run_command(TESTS_FLAKE8_COMMAND)
_run_command(FLAKE8_COMMAND)
_run_command(MYPY_COMMAND)
......@@ -42,8 +40,7 @@ class AllTests(TestCommand):
def run_tests(self):
_run_command(TESTS_COMMAND)
_run_command(TG263_FLAKE8_COMMAND)
_run_command(TESTS_FLAKE8_COMMAND)
_run_command(FLAKE8_COMMAND)
_run_command(MYPY_COMMAND)
......
# coding: utf-8
# author: Gabriel Couture
import unittest
from tg263.allowed_structure_names import is_structure_name_is_allowed
class TestAllowedStructureNames(unittest.TestCase):
def setUp(self) -> None:
self.an_allowed_structure_name = 'Prostate'
self.a_not_allowed_structure_name = 'A_NOT_ALLOWED_STRUCTURE_NAME'
def test_givenAnAllowedStructureName_whenAskingIfStructureNameIsAllowed_thenResultIsTrue(self) -> None:
result = is_structure_name_is_allowed(self.an_allowed_structure_name)
self.assertTrue(result)
def test_givenANotAllowedStructureName_whenAskingIfStructureNameIsAllowed_thenResultIsFalse(self) -> None:
result = is_structure_name_is_allowed(self.a_not_allowed_structure_name)
self.assertFalse(result)
# coding: utf-8
# author: Gabriel Couture
import functools
from tg263.dictionary import ALLOWED_STRUCTURE_NAMES
def is_structure_name_is_allowed(structure_name: str) -> bool:
return functools.reduce(
lambda j, i: j or False if i.regex.match(structure_name) is None else True,
ALLOWED_STRUCTURE_NAMES,
False
)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment