Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generated new imcsdk and updated mo, meta and respected files #248

Merged
merged 7 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
94 changes: 87 additions & 7 deletions tests/unit_tests/common/test_imcversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
from nose.tools import assert_equal
from imcsdk.imcmeta import VersionMeta
from imcsdk.imccoremeta import ImcVersion
from ..connection.info import custom_setup, custom_teardown


def setup_module():
Copy link
Member

@vvb vvb Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup_module and teardown_module must not be used in this test.
Everything under tests/unit_tests is expected to work without a connection to an actual server.

If any of your tests need the handle.login(), then you need to move them out of unit_tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure vikrant, i will update the code

global handle
handle = custom_setup()


def teardown_module():
global handle
custom_teardown(handle)


def test_nightly_version1():
Expand Down Expand Up @@ -45,35 +56,35 @@ def test_spin_version1():
# version interpreted as 4.0(2b)
version1 = ImcVersion("4.0(2aS3)")
version2 = ImcVersion("4.0(2b)")
assert_equal((version1 == version2), True)
assert_equal((version1 == version2), False)


def test_spin_version2():
# version interpreted as 4.0(234c)
version1 = ImcVersion("4.0(234bS3)")
version2 = ImcVersion("4.0(234c)")
assert_equal((version1 == version2), True)
assert_equal((version1 == version2), False)


def test_spin_version3():
# version interpreted as 4.0(2z)
version1 = ImcVersion("4.0(2S3)")
version2 = ImcVersion("4.0(2z)")
assert_equal((version1 == version2), True)
assert_equal((version1 == version2), False)


def test_spin_version4():
# version interpreted as 4.0(234z)
version1 = ImcVersion("4.0(234S3)")
version2 = ImcVersion("4.0(234z)")
assert_equal((version1 == version2), True)
assert_equal((version1 == version2), False)


def test_patch_version1():
# version interpreted as 4.0(235a)
version1 = ImcVersion("4.0(234.5)")
version2 = ImcVersion("4.0(235a)")
assert_equal((version1 == version2), True)
assert_equal((version1 == version2), False)


def test_gt_same_major_version():
Expand All @@ -89,7 +100,76 @@ def test_gt_different_major_version():


def test_patch_versions():
# when we don't see a patch version we use z
# so 2.0(12) will be considerde as 2.0(12z)
version1 = ImcVersion("2.0(12b)")
version2 = ImcVersion("2.0(12)")
assert_equal((version1 > version2), True)

assert_equal((version1 > version2), False)

def test_patch_spin_versions():
alpha_ver1 = ImcVersion("4.2(1a)")
alpha_ver2 = ImcVersion("4.2(1b)")
alpha_ver3 = ImcVersion("4.2(2a)")
alpha_ver4 = ImcVersion("4.2(3a)")
alpha_ver5 = ImcVersion("4.3(1a)")
num_ver1 = ImcVersion("4.3(2.230190)")
num_ver2 = ImcVersion("4.3(2.230191)")
num_ver3 = ImcVersion("4.3(3.230000)")
num_ver4 = ImcVersion("4.4(1.230000)")
# Verify version parts
assert_equal(alpha_ver1.major, "4")
assert_equal(alpha_ver1.minor, "2")
assert_equal(alpha_ver1.mr, "1")
assert_equal(alpha_ver1.patch, "a")
assert_equal(alpha_ver1.spin, None)
assert_equal(num_ver1.major, "4")
assert_equal(num_ver1.minor, "3")
assert_equal(num_ver1.mr, "2")
assert_equal(num_ver1.patch, None)
assert_equal(num_ver1.spin, "230190")
# Compare Patch versions
assert_equal(alpha_ver1 < alpha_ver2, True)
assert_equal(alpha_ver2 > alpha_ver1, True)
assert_equal(alpha_ver1 > alpha_ver2, False)
assert_equal(alpha_ver2 < alpha_ver1, False)
assert_equal(alpha_ver2 == alpha_ver1, False)
assert_equal(alpha_ver2 == alpha_ver2, True)
assert_equal(alpha_ver2 < alpha_ver3, True)
assert_equal(alpha_ver3 < alpha_ver4, True)
assert_equal(alpha_ver4 < alpha_ver5, True)
# Compare Patch versions with Spin versions.
assert_equal(alpha_ver5 < num_ver1, True)
assert_equal(alpha_ver5 <= num_ver1, True)
assert_equal(alpha_ver5 > num_ver1, False)
assert_equal(alpha_ver5 >= num_ver1, False)
assert_equal(alpha_ver4 < num_ver4, True)
assert_equal(alpha_ver4 < num_ver4, True)
assert_equal(alpha_ver3 > num_ver3, False)
# Compare Spin Versions.
assert_equal(num_ver1 < num_ver2, True)
assert_equal(num_ver2 > num_ver1, True)
assert_equal(num_ver2 >= num_ver1, True)
assert_equal(num_ver2 >= num_ver2, True)
assert_equal(num_ver1 >= num_ver2, False)
assert_equal(num_ver2 <= num_ver2, True)
assert_equal(num_ver2 <= num_ver1, False)
assert_equal(num_ver1 <= num_ver2, True)
assert_equal(num_ver1 <= num_ver1, True)
assert_equal(num_ver1 > num_ver2, False)
assert_equal(num_ver2 < num_ver1, False)
assert_equal(num_ver2 == num_ver1, False)
assert_equal(num_ver2 == num_ver2, True)
assert_equal(num_ver2 < num_ver3, True)
assert_equal(num_ver3 < num_ver4, True)


def test_handle_version():
global handle
assert_equal(type(handle.version), ImcVersion)


def test_handle_mo_version():
global handle
mos = handle.query_classid("BiosUnit")
mo_version = mos[0].get_version(platform=handle.platform)
assert_equal((handle.version < mo_version), False)
6 changes: 5 additions & 1 deletion tests/unit_tests/test_ipmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import patch, MagicMock
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if unittest.mock provides the same functionality, then let us use that and remove the from mock import patch, MagicMock all together. No need to do try and except.

Copy link
Contributor Author

@PavanMuchhukunta PavanMuchhukunta Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already removed vikrant, now i don changes only for "test_imcversion.py"

from unittest.mock import patch, MagicMock
except ImportError:
from mock import patch, MagicMock

from nose.tools import assert_raises
from imcsdk.imchandle import ImcHandle
from imcsdk.mometa.comm.CommIpmiLan import CommIpmiLanConsts
Expand Down
6 changes: 5 additions & 1 deletion tests/unit_tests/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import patch, MagicMock
try:
from unittest.mock import patch, MagicMock
except ImportError:
from mock import patch, MagicMock

from nose.tools import assert_raises
from imcsdk.imchandle import ImcHandle
from imcsdk.imcexception import ImcOperationError
Expand Down
6 changes: 5 additions & 1 deletion tests/unit_tests/test_vmedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import patch, call, MagicMock
try:
from unittest.mock import patch, call, MagicMock
except ImportError:
from mock import patch, call, MagicMock

from nose.tools import assert_raises
from imcsdk.imchandle import ImcHandle
from imcsdk.imcexception import ImcOperationError
Expand Down