|
|
|
@ -701,6 +701,8 @@ class TestDatavars:
|
|
|
|
|
source=Dependence('namespace_1.var_1',
|
|
|
|
|
depend=depend_function))
|
|
|
|
|
|
|
|
|
|
datavars.namespace_1.var_1[0]
|
|
|
|
|
print(datavars.namespace_1.var_1[0])
|
|
|
|
|
assert datavars.namespace_1.var_2 == 'value_2'
|
|
|
|
|
|
|
|
|
|
def test_if_variable_of_TableType_is_created_using_dependence_that_creates_table__the_created_variable_has_generated_table_as_its_value(self):
|
|
|
|
@ -731,7 +733,7 @@ class TestDatavars:
|
|
|
|
|
Variable('repositories', type=TableType,
|
|
|
|
|
source=Dependence('.config', depend=config_source))
|
|
|
|
|
|
|
|
|
|
assert datavars.os.repositories == value
|
|
|
|
|
assert datavars.os.repositories.get_table() == value
|
|
|
|
|
except ImportError:
|
|
|
|
|
# Если тестируем на другой системе модуль portage будет не найден.
|
|
|
|
|
assert True
|
|
|
|
@ -1039,7 +1041,7 @@ name = name_2
|
|
|
|
|
value = value_2
|
|
|
|
|
"""
|
|
|
|
|
namespace_filler.fill(datavars, first_ini_text)
|
|
|
|
|
assert datavars.custom.test ==\
|
|
|
|
|
assert datavars.custom.test.get_table() ==\
|
|
|
|
|
[{'name': 'name_0', 'value': 'value_0'},
|
|
|
|
|
{'name': 'name_1', 'value': 'value_1'},
|
|
|
|
|
{'name': 'name_2', 'value': 'value_2'}]
|
|
|
|
@ -1112,9 +1114,9 @@ value = weird_value
|
|
|
|
|
|
|
|
|
|
namespace_filler.fill(datavars, first_ini_text)
|
|
|
|
|
|
|
|
|
|
assert datavars.custom.test ==\
|
|
|
|
|
assert datavars.custom.test.get_table() ==\
|
|
|
|
|
[{'name': 'name_0', 'value': 'value_0'}]
|
|
|
|
|
assert datavars.os.test ==\
|
|
|
|
|
assert datavars.os.test.get_table() ==\
|
|
|
|
|
[{'name': 'strange_name', 'value': 'weird_value'}]
|
|
|
|
|
|
|
|
|
|
def test_if_calculate_ini_file_is_used_for_modifying_of_the_table_from_calculate_ini_file__the_NamespaceIniFiller_object_modifies_the_table(self):
|
|
|
|
@ -1134,7 +1136,7 @@ value = value_1
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
namespace_filler.fill(datavars, first_ini_text)
|
|
|
|
|
assert datavars.custom.test ==\
|
|
|
|
|
assert datavars.custom.test.get_table() ==\
|
|
|
|
|
[{'name': 'name_0', 'value': 'value_0'},
|
|
|
|
|
{'name': 'name_1', 'value': 'value_1'}]
|
|
|
|
|
|
|
|
|
@ -1145,7 +1147,7 @@ value = another_value
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
namespace_filler.fill(datavars, second_ini_text)
|
|
|
|
|
assert datavars.custom.test ==\
|
|
|
|
|
assert datavars.custom.test.get_table() ==\
|
|
|
|
|
[{'name': 'name_0', 'value': 'value_0'},
|
|
|
|
|
{'name': 'other_name', 'value': 'another_value'}]
|
|
|
|
|
|
|
|
|
@ -1173,7 +1175,7 @@ value = another_value
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
namespace_filler.fill(datavars, first_ini_text)
|
|
|
|
|
assert datavars.namespace_1.test ==\
|
|
|
|
|
assert datavars.namespace_1.test.get_table() ==\
|
|
|
|
|
[{'name': 'new_name', 'value': 'other_value'},
|
|
|
|
|
{'name': 'common_name', 'value': 'another_value'},
|
|
|
|
|
{'name': 'name_3', 'value': 'value_3'}]
|
|
|
|
@ -1211,12 +1213,13 @@ value = another_value
|
|
|
|
|
assert datavars.level.use_local_simple == "Using simple value"
|
|
|
|
|
assert datavars.level.use_full_simple == "Using simple value"
|
|
|
|
|
assert datavars.level.device_child == "hdd"
|
|
|
|
|
assert datavars.level.device == [{"dev": "/dev/sda",
|
|
|
|
|
"type": "hdd",
|
|
|
|
|
"name": "Samsung SSD"},
|
|
|
|
|
{"dev": "/dev/sdb",
|
|
|
|
|
"type": "flash",
|
|
|
|
|
"name": "Transcend 64GB"}]
|
|
|
|
|
assert datavars.level.device.get_table() == [
|
|
|
|
|
{"dev": "/dev/sda",
|
|
|
|
|
"type": "hdd",
|
|
|
|
|
"name": "Samsung SSD"},
|
|
|
|
|
{"dev": "/dev/sdb",
|
|
|
|
|
"type": "flash",
|
|
|
|
|
"name": "Transcend 64GB"}]
|
|
|
|
|
|
|
|
|
|
def test_if_a_Datavars_object_is_created_with_path_to_the_variables_with_Dependencies_and_then_the_variables_are_changed_using_calculate_ini_files_and_the_datavars_object_used_to_get_access_to_the_some_variables_from__the_datavars_object_dynamically_loads_variables_and_retruns_necessary_variables(self):
|
|
|
|
|
datavars = Datavars(
|
|
|
|
@ -1270,7 +1273,7 @@ value = another_value
|
|
|
|
|
assert datavars.os.hashvar.value1 == 'new1'
|
|
|
|
|
assert datavars.os.hashvar.value2 == 'new2'
|
|
|
|
|
|
|
|
|
|
assert datavars.os.tablevar == [
|
|
|
|
|
assert datavars.os.tablevar.get_table() == [
|
|
|
|
|
{'dev': '/dev/sda1', 'mount': 'swap'},
|
|
|
|
|
{'dev': '/dev/sda2', 'mount': '/'},
|
|
|
|
|
{'dev': '/dev/sda5', 'mount': '/var/calculate'}]
|
|
|
|
@ -1288,7 +1291,7 @@ value = another_value
|
|
|
|
|
assert datavars.os.hashvar.value1 == 'new1'
|
|
|
|
|
assert datavars.os.hashvar.value2 == 'new2'
|
|
|
|
|
|
|
|
|
|
assert datavars.os.tablevar == [
|
|
|
|
|
assert datavars.os.tablevar.get_table() == [
|
|
|
|
|
{'dev': '/dev/sda1', 'mount': 'swap'},
|
|
|
|
|
{'dev': '/dev/sda2', 'mount': '/'},
|
|
|
|
|
{'dev': '/dev/sda5', 'mount': '/var/calculate'}]
|
|
|
|
@ -1635,3 +1638,17 @@ os.linux.test_3 = {{ os.linux.test_3 }}
|
|
|
|
|
|
|
|
|
|
shutil.rmtree(os.path.join(TESTFILES_PATH, 'ini_vars'))
|
|
|
|
|
assert not os.path.exists(os.path.join(TESTFILES_PATH, 'ini_vars'))
|
|
|
|
|
|
|
|
|
|
def test_getting_value_of_the_unexisting_row(self):
|
|
|
|
|
Namespace.reset()
|
|
|
|
|
datavars = Namespace.datavars
|
|
|
|
|
|
|
|
|
|
with Namespace('namespace_1'):
|
|
|
|
|
Variable('var_1', type=TableType, source=[{'name': 'name_1',
|
|
|
|
|
'value': 'value_1'},
|
|
|
|
|
{'name': 'name_2',
|
|
|
|
|
'value': 'value_2'},
|
|
|
|
|
{'name': 'name_3',
|
|
|
|
|
'value': 'value_3'}])
|
|
|
|
|
|
|
|
|
|
assert datavars.namespace_1.var_1[3]['value'] is None
|
|
|
|
|