Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vibaswan committed May 16, 2024
1 parent 02e21b2 commit 063ac13
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
39 changes: 18 additions & 21 deletions openapiart/tests/new_tests/test_status_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,26 @@ def test_status_warning_for_primitive_attr(api, capsys):
s_obj = config.serialize()

out, err = capsys.readouterr()
print("wohoooo")
print(out)
assert err == ""
assert out == ""
assert (
"[WARNING]: decprecated_property_2 property in schema XStatusObject is deprecated, test deprecated"
in out
in err
)
assert (
"[WARNING]: under_review_property_2 property in schema XStatusObject is under_review, test under_review"
in out
in err
)

config.deserialize(s_obj)
out, err = capsys.readouterr()
assert err == ""
assert err == ""
assert out == ""
assert (
"[WARNING]: decprecated_property_2 property in schema XStatusObject is deprecated, test deprecated"
in out
in err
)
assert (
"[WARNING]: under_review_property_2 property in schema XStatusObject is under_review, test under_review"
in out
in err
)


Expand All @@ -43,18 +40,18 @@ def test_warnings_for_non_primitive_attr(api, capsys):
s_obj = config.serialize(config.DICT)
out, err = capsys.readouterr()

assert err == ""
assert out == ""
assert (
"x_status_object property in schema ExtendedFeatures is under_review, test under_review"
in out
in err
)

config.deserialize(s_obj)
out, err = capsys.readouterr()
assert err == ""
assert out == ""
assert (
"x_status_object property in schema ExtendedFeatures is under_review, test under_review"
in out
in err
)


Expand All @@ -66,18 +63,18 @@ def test_warnings_for_x_enmu_attr(api, capsys):
s_obj = config.serialize(config.DICT)
out, err = capsys.readouterr()

assert err == ""
assert out == ""
assert (
"DECPRECATED_PROPERTY_1 enum in property enum_property is deprecated, test deprecated"
in out
in err
)

config.deserialize(s_obj)
out, err = capsys.readouterr()
assert err == ""
assert out == ""
assert (
"DECPRECATED_PROPERTY_1 enum in property enum_property is deprecated, test deprecated"
in out
in err
)


Expand All @@ -89,16 +86,16 @@ def test_warnings_for_schema(api, capsys):
s_obj = config.serialize(config.DICT)
out, err = capsys.readouterr()

assert err == ""
assert out == ""
assert (
"TestConfig is under_review, the whole schema is being reviewed" in out
"TestConfig is under_review, the whole schema is being reviewed" in err
)

config.deserialize(s_obj)
out, err = capsys.readouterr()
assert err == ""
assert out == ""
assert (
"TestConfig is under_review, the whole schema is being reviewed" in out
"TestConfig is under_review, the whole schema is being reviewed" in err
)


Expand Down
30 changes: 15 additions & 15 deletions pkg/serdes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,77 +350,77 @@ func TestAuto(t *testing.T) {
}

func TestAutoHeirarchy(t *testing.T) {
config := openapiart.NewPrefixConfig()
config := goapi.NewPrefixConfig()
config.SetA("asdf").SetB(12.2).SetC(1)
config.RequiredObject().SetEA(1).SetEB(2)
assert.Equal(
t,
openapiart.PatternAutoPatternAutoIpChoice.VALUE,
goapi.PatternAutoPatternAutoIpChoice.VALUE,
config.AutoPattern().AutoIp().Choice())

config.AutoPattern().AutoIp().Auto().Static()
assert.Equal(
t,
openapiart.PatternAutoPatternAutoIpChoice.AUTO,
goapi.PatternAutoPatternAutoIpChoice.AUTO,
config.AutoPattern().AutoIp().Choice())
assert.Equal(
t,
openapiart.AutoIpOptionsChoice.STATIC,
goapi.AutoIpOptionsChoice.STATIC,
config.AutoPattern().AutoIp().Auto().Choice())

config.AutoPattern().AutoIp().Auto().Dhcp()
assert.Equal(
t,
openapiart.PatternAutoPatternAutoIpChoice.AUTO,
goapi.PatternAutoPatternAutoIpChoice.AUTO,
config.AutoPattern().AutoIp().Choice())
assert.Equal(
t,
openapiart.AutoIpOptionsChoice.DHCP,
goapi.AutoIpOptionsChoice.DHCP,
config.AutoPattern().AutoIp().Auto().Choice())

config.AutoPattern().AutoIp().SetValues([]string{"10"})
assert.Equal(
t,
openapiart.PatternAutoPatternAutoIpChoice.VALUES,
goapi.PatternAutoPatternAutoIpChoice.VALUES,
config.AutoPattern().AutoIp().Choice())
}

func TestAutoHeirarchyDefault(t *testing.T) {
config := openapiart.NewPrefixConfig()
config := goapi.NewPrefixConfig()
config.SetA("asdf").SetB(12.2).SetC(1)
config.RequiredObject().SetEA(1).SetEB(2)
assert.Equal(
t,
openapiart.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
goapi.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
config.AutoPatternDefault().AutoIpDefault().Choice())
assert.Equal(
t,
openapiart.AutoIpDefaultChoice.DHCP,
goapi.AutoIpDefaultChoice.DHCP,
config.AutoPatternDefault().AutoIpDefault().Auto().Choice())

config.AutoPatternDefault().AutoIpDefault().Auto().Static()
assert.Equal(
t,
openapiart.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
goapi.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
config.AutoPatternDefault().AutoIpDefault().Choice())
assert.Equal(
t,
openapiart.AutoIpDefaultChoice.STATIC,
goapi.AutoIpDefaultChoice.STATIC,
config.AutoPatternDefault().AutoIpDefault().Auto().Choice())

config.AutoPatternDefault().AutoIpDefault().Auto().Dhcp()
assert.Equal(
t,
openapiart.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
goapi.PatternAutoPatternDefaultAutoIpDefaultChoice.AUTO,
config.AutoPatternDefault().AutoIpDefault().Choice())
assert.Equal(
t,
openapiart.AutoIpDefaultChoice.DHCP,
goapi.AutoIpDefaultChoice.DHCP,
config.AutoPatternDefault().AutoIpDefault().Auto().Choice())

config.AutoPatternDefault().AutoIpDefault().SetValues([]string{"10"})
assert.Equal(
t,
openapiart.PatternAutoPatternDefaultAutoIpDefaultChoice.VALUES,
goapi.PatternAutoPatternDefaultAutoIpDefaultChoice.VALUES,
config.AutoPatternDefault().AutoIpDefault().Choice())
}

0 comments on commit 063ac13

Please sign in to comment.