Rendered files pyCharm compliant
This commit is contained in:
parent
4885ff2467
commit
c3eeef1aff
|
|
@ -4,7 +4,7 @@
|
||||||
import rich
|
import rich
|
||||||
|
|
||||||
|
|
||||||
class environment():
|
class Environment:
|
||||||
"""
|
"""
|
||||||
Object containing all the important variables,
|
Object containing all the important variables,
|
||||||
with appropriate getters and setters.
|
with appropriate getters and setters.
|
||||||
|
|
@ -32,7 +32,7 @@ class environment():
|
||||||
# Set all parameters to uninitialised
|
# Set all parameters to uninitialised
|
||||||
self._wasInitialised = {p: False for p in self._mParams}
|
self._wasInitialised = {p: False for p in self._mParams}
|
||||||
|
|
||||||
def integritycheck(self):
|
def integrity_check(self):
|
||||||
for value in self._wasInitialised.values():
|
for value in self._wasInitialised.values():
|
||||||
if value is False:
|
if value is False:
|
||||||
return False
|
return False
|
||||||
|
|
@ -56,4 +56,4 @@ class environment():
|
||||||
elif attribute in self._sParams:
|
elif attribute in self._sParams:
|
||||||
self._sParams[attribute] = value
|
self._sParams[attribute] = value
|
||||||
else:
|
else:
|
||||||
raise AttributeError(attribute) # Could also add attribute as a new entry
|
raise AttributeError(attribute) # Could also add attribute as a new entry
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ def create_config():
|
||||||
|
|
||||||
def create_crawler():
|
def create_crawler():
|
||||||
"""
|
"""
|
||||||
Returns crawler as an object for navigation in the userfiles.
|
Returns crawler as an object for navigation in the user files.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ def env_checker():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def begin_crawling(pEnv):
|
def begin_crawling(p_env):
|
||||||
"""
|
"""
|
||||||
Starts reading every file in the userfiles and
|
Starts reading every file in the userfiles and
|
||||||
adds them to the crawler object progressively.
|
adds them to the crawler object progressively.
|
||||||
|
|
@ -66,7 +66,7 @@ def begin_crawling(pEnv):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def begin_preparsing(pEnv):
|
def begin_pre_parsing(p_env):
|
||||||
"""
|
"""
|
||||||
Create an importTree and checks for conflicts or loops;
|
Create an importTree and checks for conflicts or loops;
|
||||||
then replaces imports with their contents,
|
then replaces imports with their contents,
|
||||||
|
|
@ -75,7 +75,7 @@ def begin_preparsing(pEnv):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def begin_parsing(pEnv):
|
def begin_parsing(p_env):
|
||||||
"""
|
"""
|
||||||
For each of the generated files,
|
For each of the generated files,
|
||||||
parses element after element and creates
|
parses element after element and creates
|
||||||
|
|
@ -89,7 +89,7 @@ def begin_parsing(pEnv):
|
||||||
def begin_export():
|
def begin_export():
|
||||||
"""
|
"""
|
||||||
Replaces all parsed values with their attributed
|
Replaces all parsed values with their attributed
|
||||||
correspondances as per the template_manager
|
correspondences as per the template_manager
|
||||||
and exports the result as a website.
|
and exports the result as a website.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -2,71 +2,71 @@ from logging import exception
|
||||||
import bootstraparse.modules.environment as e
|
import bootstraparse.modules.environment as e
|
||||||
|
|
||||||
|
|
||||||
def test_wasInitialised():
|
def test_was_initialised():
|
||||||
testcheck = e.environment()
|
test_check = e.Environment()
|
||||||
for k in testcheck._wasInitialised.values():
|
for k in test_check._wasInitialised.values():
|
||||||
assert k is False
|
assert k is False
|
||||||
|
|
||||||
|
|
||||||
def test_integritycheck():
|
def test_integrity_check():
|
||||||
testcheck = e.environment()
|
test_check = e.Environment()
|
||||||
customtest_p = [p for p in testcheck._mParams.keys()]
|
custom_test_p = [p for p in test_check._mParams.keys()]
|
||||||
customtest_v = [False for p in testcheck._mParams.values()]
|
custom_test_v = [False for p in test_check._mParams.values()]
|
||||||
# Test all False
|
# Test all False
|
||||||
# rich.inspect(testcheck)
|
# rich.inspect(test_check)
|
||||||
|
|
||||||
assert testcheck.integritycheck() is False
|
assert test_check.integrity_check() is False
|
||||||
|
|
||||||
customtest_v[0] = True
|
custom_test_v[0] = True
|
||||||
testcheck._wasInitialised = dict(zip(customtest_p, customtest_v))
|
test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))
|
||||||
# Test first False
|
# Test first False
|
||||||
# rich.inspect(testcheck)
|
# rich.inspect(test_check)
|
||||||
|
|
||||||
assert testcheck.integritycheck() is False
|
assert test_check.integrity_check() is False
|
||||||
|
|
||||||
customtest_v[0] = False
|
custom_test_v[0] = False
|
||||||
customtest_v[-1] = True
|
custom_test_v[-1] = True
|
||||||
testcheck._wasInitialised = dict(zip(customtest_p, customtest_v))
|
test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))
|
||||||
# Test last False
|
# Test last False
|
||||||
# rich.inspect(testcheck)
|
# rich.inspect(test_check)
|
||||||
|
|
||||||
assert testcheck.integritycheck() is False
|
assert test_check.integrity_check() is False
|
||||||
|
|
||||||
customtest_v[-1] = False
|
custom_test_v[-1] = False
|
||||||
customtest_v[len(customtest_v)//2-1] = True
|
custom_test_v[len(custom_test_v)//2-1] = True
|
||||||
testcheck._wasInitialised = dict(zip(customtest_p, customtest_v))
|
test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))
|
||||||
# Test middle False
|
# Test middle False
|
||||||
# rich.inspect(testcheck)
|
# rich.inspect(test_check)
|
||||||
|
|
||||||
assert testcheck.integritycheck() is False
|
assert test_check.integrity_check() is False
|
||||||
|
|
||||||
customtest_v = [True for p in testcheck._mParams.values()]
|
custom_test_v = [True for p in test_check._mParams.values()]
|
||||||
testcheck._wasInitialised = dict(zip(customtest_p, customtest_v))
|
test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))
|
||||||
# Test all True
|
# Test all True
|
||||||
# rich.inspect(testcheck)
|
# rich.inspect(test_check)
|
||||||
|
|
||||||
assert testcheck.integritycheck() is True
|
assert test_check.integrity_check() is True
|
||||||
|
|
||||||
|
|
||||||
def test_getter():
|
def test_getter():
|
||||||
testcheck = e.environment()
|
test_check = e.Environment()
|
||||||
for p in testcheck._mParams:
|
for p in test_check._mParams:
|
||||||
assert testcheck.__getattr__(p) == testcheck._mParams[p]
|
assert test_check.__getattr__(p) == test_check._mParams[p]
|
||||||
|
|
||||||
testcheck._sParams = {
|
test_check._sParams = {
|
||||||
"testparam": "testvalue"
|
"test_param": "test_value"
|
||||||
}
|
}
|
||||||
assert testcheck.testparam == "testvalue"
|
assert test_check.test_param == "test_value"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
testcheck.purposefullyunexistingparameter
|
test_check.purposefullyunexistingparameter
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
assert False # Not AttributeError when getting unexisting parameter
|
assert False # Not AttributeError when getting unexisting parameter
|
||||||
|
|
||||||
try:
|
try:
|
||||||
testcheck._purposefullyunexistingparameter
|
test_check._purposefullyunexistingparameter
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -74,26 +74,26 @@ def test_getter():
|
||||||
|
|
||||||
|
|
||||||
def test_setter():
|
def test_setter():
|
||||||
testcheck = e.environment()
|
test_check = e.Environment()
|
||||||
for p in testcheck._mParams:
|
for p in test_check._mParams:
|
||||||
testcheck.__setattr__(p, "testvalue")
|
test_check.__setattr__(p, "test_value")
|
||||||
assert testcheck._mParams[p] == "testvalue"
|
assert test_check._mParams[p] == "test_value"
|
||||||
|
|
||||||
testcheck._sParams = {
|
test_check._sParams = {
|
||||||
"testparam": "testvalue"
|
"test_param": "test_value"
|
||||||
}
|
}
|
||||||
testcheck.testparam = "secondtestvalue"
|
test_check.test_param = "second_test_value"
|
||||||
assert testcheck.testparam == "secondtestvalue"
|
assert test_check.test_param == "second_test_value"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
testcheck.purposefullyunexistingparameter = "testvalue"
|
test_check.purposefullyunexistingparameter = "test_value"
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
assert False # Not AttributeError when getting unexisting parameter
|
assert False # Not AttributeError when getting unexisting parameter
|
||||||
|
|
||||||
testcheck._purposefullyunexistingparameter = "testvalue"
|
test_check._purposefullyunexistingparameter = "test_value"
|
||||||
assert testcheck._purposefullyunexistingparameter == "testvalue"
|
assert test_check._purposefullyunexistingparameter == "test_value"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue