Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/implementation/v00/configuration_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def __init__(
assert isinstance(cfgOsOps, ConfigurationOsOps)

super().__init__(data_dir, cfgOsOps)
return

# --------------------------------------------------------------------
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def test_001__int_opt(self, request: pytest.FixtureRequest, optName: str):
__class__.Helper__CheckStateOfCfgWithOneIntOpt(cfg, option, optName, 123)

# Amen
return

# --------------------------------------------------------------------
@staticmethod
def Helper__CheckStateOfCfgWithOneIntOpt(
cfg: PgCfg_Std, opt: PgCfg_Option_Base, optName: str, optValue: int
):
Expand Down Expand Up @@ -120,6 +122,7 @@ def Helper__CheckStateOfCfgWithOneIntOpt(
assert optName in cfg.m_Data.m_AllOptionsByName.keys()
assert len(cfg.m_Data.m_AllOptionsByName.values()) == 1
assert opt.m_OptionData in cfg.m_Data.m_AllOptionsByName.values()
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand All @@ -136,6 +139,7 @@ def test_002__None_value(self, request: pytest.FixtureRequest, optName: str):

with pytest.raises(Exception, match=re.escape("None value is not supported.")):
cfg.AddOption(optName, None)
return

# --------------------------------------------------------------------
def test_003__empty_name(self, request: pytest.FixtureRequest):
Expand All @@ -150,6 +154,7 @@ def test_003__empty_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is empty.")):
cfg.AddOption("", 123)
return

# --------------------------------------------------------------------
def test_004__None_name(self, request: pytest.FixtureRequest):
Expand All @@ -164,6 +169,7 @@ def test_004__None_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is None.")):
cfg.AddOption(None, 123)
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand Down Expand Up @@ -192,6 +198,7 @@ def test_005__already_defined(self, request: pytest.FixtureRequest, optName: str

assert option.get_Name() == optName
assert option.get_Value() == 123
return


# //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_001(self, request: pytest.FixtureRequest):
cfg.SetOptionValue("port", None)

assert len(file1.get_Lines()) == 0
return


# //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_001__port(self, request: pytest.FixtureRequest, optName: str):
assert type(set_r) is PgCfg_SetOptionResult_Base
assert isinstance(set_r, PgCfg_SetOptionResult)
assert set_r.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_ADDED
set_r_option: PgCfg_Option_Base = set_r.Option
set_r_option = set_r.Option
assert set_r_option is not None
assert type(set_r_option) is PgCfg_Option_Base
assert isinstance(set_r_option, PostgresConfigurationOption)
Expand All @@ -52,6 +52,7 @@ def test_001__port(self, request: pytest.FixtureRequest, optName: str):
get_r = cfg.GetOptionValue(optName)
assert type(get_r) is int
assert get_r == 123
return

# --------------------------------------------------------------------
def test_002__None_name(self, request: pytest.FixtureRequest):
Expand All @@ -64,6 +65,7 @@ def test_002__None_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is None.")):
cfg.GetOptionValue(None)
return

# --------------------------------------------------------------------
def test_003__empty_name(self, request: pytest.FixtureRequest):
Expand All @@ -76,6 +78,7 @@ def test_003__empty_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is empty.")):
cfg.GetOptionValue("")
return

# --------------------------------------------------------------------
def test_004__opt_with_list__get_None(self, request: pytest.FixtureRequest):
Expand All @@ -91,6 +94,7 @@ def test_004__opt_with_list__get_None(self, request: pytest.FixtureRequest):
v = cfg.GetOptionValue(C_OPT_NAME)

assert v is None
return


# //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_001__get_Configuration(self, request: pytest.FixtureRequest):
assert cfg.m_Data.m_DataDir == rootTmpDir

assert cfg.get_Configuration() is cfg
return

# --------------------------------------------------------------------
def test_002__get_Parent(self, request: pytest.FixtureRequest):
Expand All @@ -40,6 +41,7 @@ def test_002__get_Parent(self, request: pytest.FixtureRequest):
assert cfg.m_Data.m_DataDir == rootTmpDir

assert cfg.get_Parent() is None
return


# //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_001__int_opt(self, request: pytest.FixtureRequest, optName: str):
assert type(r) is PgCfg_SetOptionResult_Base
assert isinstance(r, PgCfg_SetOptionResult)
assert r.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_ADDED
r_option: PgCfg_Option_Base = r.Option
r_option = r.Option
assert r_option is not None
assert type(r_option) is PgCfg_Option_Base
assert isinstance(r_option, PostgresConfigurationOption)
Expand All @@ -62,6 +62,7 @@ def test_001__int_opt(self, request: pytest.FixtureRequest, optName: str):
__class__.Helper__CheckStateOfCfgWithOneOpt(cfg, r_option, optName, 123)

# Amen
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand All @@ -80,15 +81,17 @@ def test_002__port___reasign(self, request: pytest.FixtureRequest, optName: str)
r = cfg.SetOptionValue(optName, 321)
assert type(r) is PgCfg_SetOptionResult_Base
assert r.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_UPDATED
r_option: PgCfg_Option_Base = r.Option
r_option = r.Option
assert r_option is not None
assert type(r_option) is PgCfg_Option_Base
assert isinstance(r_option, PostgresConfigurationOption)
assert r.Option is r_option # check a cache

__class__.Helper__CheckStateOfCfgWithOneOpt(cfg, r_option, optName, 321)
return

# --------------------------------------------------------------------
@staticmethod
def Helper__CheckStateOfCfgWithOneOpt(
cfg: PgCfg_Std, opt: PgCfg_Option_Base, optName: str, optValue: typing.Any
):
Expand Down Expand Up @@ -156,6 +159,7 @@ def Helper__CheckStateOfCfgWithOneOpt(
assert optName in cfg.m_Data.m_AllOptionsByName.keys()
assert len(cfg.m_Data.m_AllOptionsByName.values()) == 1
assert opt.m_OptionData in cfg.m_Data.m_AllOptionsByName.values()
return

# --------------------------------------------------------------------
def test_003__port___bad_type(self, request: pytest.FixtureRequest):
Expand All @@ -173,6 +177,7 @@ def test_003__port___bad_type(self, request: pytest.FixtureRequest):
),
):
cfg.SetOptionValue("port", True)
return

# --------------------------------------------------------------------
def test_004__port___cont_convert_value(self, request: pytest.FixtureRequest):
Expand All @@ -190,6 +195,7 @@ def test_004__port___cont_convert_value(self, request: pytest.FixtureRequest):
),
):
cfg.SetOptionValue("port", "123.")
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand All @@ -207,12 +213,14 @@ def test_006(self, request: pytest.FixtureRequest, optName: str):
r1 = cfg.SetOptionValue(optName, 123)
assert type(r1) is PgCfg_SetOptionResult_Base
assert r1.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_ADDED
assert r1.Option is not None
assert r1.Option.get_Name() == optName
assert r1.Option.get_Value() == 123

r2 = cfg.SetOptionValue(optName, 321)
assert type(r2) is PgCfg_SetOptionResult_Base
assert r2.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_UPDATED
assert r2.Option is not None
assert r2.Option.get_Name() == optName
assert r2.Option.get_Value() == 321

Expand All @@ -223,11 +231,13 @@ def test_006(self, request: pytest.FixtureRequest, optName: str):
assert type(r3) is PgCfg_SetOptionResult_Base
assert r3.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_UPDATED
assert r3.Option is r1.Option
assert r3.Option is not None
assert r3.Option.get_Name() == optName
assert r3.Option.get_Value() == 555

assert r1.Option.get_Value() == 555
assert r2.Option.get_Value() == 555
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand All @@ -249,6 +259,7 @@ def test_007__set_None(self, request: pytest.FixtureRequest, optName: str):
assert r.m_Opt is None
assert r.m_OptData is None
assert r.Option is None
return

# --------------------------------------------------------------------
@pytest.mark.parametrize("optName", sm_OPTS001, ids=lambda x: f"{x}")
Expand Down Expand Up @@ -318,6 +329,7 @@ def test_008__set_Int_set_None(self, request: pytest.FixtureRequest, optName: st
assert r3.m_Opt is None
assert r3.m_OptData is None
assert r3.Option is None
return

# --------------------------------------------------------------------
def test_009__spec_file(self, request: pytest.FixtureRequest):
Expand Down Expand Up @@ -354,6 +366,7 @@ def test_009__spec_file(self, request: pytest.FixtureRequest):
assert type(rs1.m_OptData) is PgCfgModel__OptionData
assert rs1.m_OptData.m_Value == optValue
assert rs1.m_OptData.m_Name == C_OPT_NAME
assert rs1.Option is not None
assert rs1.Option.get_Name() == C_OPT_NAME
assert rs1.Option.get_Value() == optValue
assert rs1.Option.get_Configuration() is cfg
Expand All @@ -380,6 +393,8 @@ def test_009__spec_file(self, request: pytest.FixtureRequest):
cfg.SetOptionValue(C_OPT_NAME, None)

assert len(file1.get_Lines()) == 0
continue
return

# --------------------------------------------------------------------
def test_010__None_name(self, request: pytest.FixtureRequest):
Expand All @@ -392,6 +407,7 @@ def test_010__None_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is None.")):
cfg.SetOptionValue(None, 123)
return

# --------------------------------------------------------------------
def test_011__empty_name(self, request: pytest.FixtureRequest):
Expand All @@ -404,6 +420,7 @@ def test_011__empty_name(self, request: pytest.FixtureRequest):

with pytest.raises(Exception, match=re.escape("Option name is empty.")):
cfg.SetOptionValue("", 123)
return

# --------------------------------------------------------------------
sm_data012__values: typing.List[typing.Tuple[str, str, typing.Any, typing.Any]] = [
Expand Down Expand Up @@ -443,7 +460,7 @@ def test_012__one_opt(
assert type(r) is PgCfg_SetOptionResult_Base
assert isinstance(r, PgCfg_SetOptionResult)
assert r.m_EventID == PgCfg_SetOptionEventID.OPTION_WAS_ADDED
r_option: PgCfg_Option_Base = r.Option
r_option = r.Option
assert r_option is not None
assert type(r_option) is PgCfg_Option_Base
assert isinstance(r_option, PostgresConfigurationOption)
Expand All @@ -452,6 +469,7 @@ def test_012__one_opt(
__class__.Helper__CheckStateOfCfgWithOneOpt(
cfg, r_option, data012[0], data012[2]
)
return


# //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def test_001(self, request: pytest.FixtureRequest):
assert r1.Option.get_Value() == ["biha"]

assert cfg.GetOptionValue(C_OPT_NAME) == ["biha"]
continue
return

# --------------------------------------------------------------------
def test_002(self, request: pytest.FixtureRequest):
Expand Down Expand Up @@ -124,6 +126,7 @@ def test_002(self, request: pytest.FixtureRequest):
assert r1.m_OptData.m_Value[i] is not None
assert type(r1.m_OptData.m_Value[i]) is str
assert r1.m_OptData.m_Value[i] == expectedValue[i]
continue

assert r1.m_OptData.m_Value == expectedValue

Expand All @@ -134,6 +137,8 @@ def test_002(self, request: pytest.FixtureRequest):
assert r1.Option.get_Value() == expectedValue

assert cfg.GetOptionValue(C_OPT_NAME) == expectedValue
continue
return

# --------------------------------------------------------------------
def test_003(self, request: pytest.FixtureRequest):
Expand All @@ -152,7 +157,9 @@ def test_003(self, request: pytest.FixtureRequest):

assert r1.m_OptData is r2.m_OptData

assert r1.Option is not None
assert r1.Option.get_Value() == ["biha", "proxima"]
return

# --------------------------------------------------------------------
def test_004__check_get_prepare_filter__unique(
Expand All @@ -169,13 +176,16 @@ def test_004__check_get_prepare_filter__unique(

r1 = cfg.SetOptionValueItem(C_OPT_NAME, "biha")

assert r1.m_OptData is not None
assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option is not None
assert r1.Option.get_Value() == ["biha"]

r1.m_OptData.m_Value.append("biha")

assert r1.m_OptData.m_Value == ["biha", "biha"]
assert r1.Option.get_Value() == ["biha"]
return

# --------------------------------------------------------------------
def test_005__check_get_prepare_filter__to_str(
Expand All @@ -192,7 +202,9 @@ def test_005__check_get_prepare_filter__to_str(

r1 = cfg.SetOptionValueItem(C_OPT_NAME, "biha")

assert r1.m_OptData is not None
assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option is not None
assert r1.Option.get_Value() == ["biha"]

r1.m_OptData.m_Value.append(1)
Expand All @@ -201,6 +213,7 @@ def test_005__check_get_prepare_filter__to_str(
assert r1.m_OptData.m_Value != ["biha", "1"]
assert r1.Option.get_Value() == ["biha", "1"]
assert r1.Option.get_Value() != ["biha", 1]
return

# --------------------------------------------------------------------
def test_006__set_value_item_with_bad_type(self, request: pytest.FixtureRequest):
Expand All @@ -215,7 +228,9 @@ def test_006__set_value_item_with_bad_type(self, request: pytest.FixtureRequest)

r1 = cfg.SetOptionValueItem(C_OPT_NAME, "biha")

assert r1.m_OptData is not None
assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option is not None
assert r1.Option.get_Value() == ["biha"]

errMsg = (
Expand All @@ -229,6 +244,7 @@ def test_006__set_value_item_with_bad_type(self, request: pytest.FixtureRequest)

assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option.get_Value() == ["biha"]
return

# --------------------------------------------------------------------
def test_007__set_None(self, request: pytest.FixtureRequest):
Expand All @@ -243,7 +259,9 @@ def test_007__set_None(self, request: pytest.FixtureRequest):

r1 = cfg.SetOptionValueItem(C_OPT_NAME, "biha")

assert r1.m_OptData is not None
assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option is not None
assert r1.Option.get_Value() == ["biha"]

errMsg = "None value is not supported."
Expand All @@ -253,6 +271,7 @@ def test_007__set_None(self, request: pytest.FixtureRequest):

assert r1.m_OptData.m_Value == ["biha"]
assert r1.Option.get_Value() == ["biha"]
return


# //////////////////////////////////////////////////////////////////////////////
Loading