Skip to content

Commit

Permalink
Add unittest for env_value_to_dict
Browse files Browse the repository at this point in the history
Optimise import
  • Loading branch information
JohnDing1995 committed Jun 11, 2019
1 parent ab80427 commit ccaa7c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 4 additions & 5 deletions apluslms_roman/builder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import logging
from os import environ, getuid, getegid
from os.path import isdir, join
from os import getuid, getegid
from os.path import isdir

from apluslms_yamlidator.utils.collections import OrderedDict
from apluslms_yamlidator.utils.decorator import cached_property
from apluslms_yamlidator.utils.collections import OrderedDict, ChangesDict
from apluslms_roman.utils.path_mapping import get_host_path, load_from_env, get_pair_form_env

from apluslms_roman.utils.path_mapping import load_from_env
from .backends import BACKENDS, BuildTask, BuildStep, Environment
from .observer import StreamObserver
from .utils.importing import import_string
from .utils.translation import _


logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

Expand Down
13 changes: 11 additions & 2 deletions tests/test_json_regex.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import re
import unittest
from json import loads, dumps
from apluslms_roman.utils.path_mapping import json_re, env_value_to_dict

json_re = re.compile(r'^(?:["[{]|(?:-?[1-9]\d*(?:\.\d+)?|null|true|false)$)')
test_case_loadable = (
True,
False,
Expand All @@ -23,6 +22,7 @@
"0123123",
)


def try_loads_json(json_str):
try:
data = loads(json_str)
Expand Down Expand Up @@ -53,3 +53,12 @@ def test_not_loadable_equal(self):
with self.subTest(i=i):
self.assertNotEqual(try_loads_json(dumps(case)), -1, msg="Testing:{}".format(case))

def test_loadable_type(self):
for i, case in enumerate(test_case_loadable):
with self.subTest(i=i):
self.assertNotEqual(env_value_to_dict(dumps(case)), dumps(case), msg="Testing:{}".format(case))

def test_not_loadable_type(self):
for i, case in enumerate(test_case_not_loadable):
with self.subTest(i=i):
self.assertEqual(env_value_to_dict(case), case, msg="Testing:{}".format(case))

0 comments on commit ccaa7c5

Please sign in to comment.