Files
test/keywords/python/product_version.py
croy 931c6c208d Cloud Platform Version Manager
Implementation of a Version Manager that allows users to
get the sw_version of the Cloud Platform in an object that
is easy to compare with other releases. The strong typing
allows for easy usage check of each version.

Change-Id: Idb100e05d118368bfb9cb7e9f1f380c31ecd7b07
2025-02-04 16:13:43 -05:00

64 lines
1.8 KiB
Python

class ProductVersion:
"""
This class models a ProductVersion as an object.
ProductVersions have names and can also be compared chronologically.
"""
def __init__(self, version_name: str, version_id: int):
"""
Constructor
Args:
version_name (str): The String name of the Product Version
version_id (int) : Integers assigned for comparing release order
"""
self.version_name = version_name
self.version_id = version_id
def __str__(self) -> str:
return self.version_name
def __hash__(self):
return hash(self.version_name)
def __eq__(self, other):
return hash(self) == hash(other)
def get_name(self) -> str:
"""
Getter for the name of this version
Returns:
"""
return self.version_name
def get_id(self) -> int:
"""
Getter for the id of this version
Returns:
"""
return self.version_id
def is_before_or_equal_to(self, other_product_version) -> bool:
"""
Returns true if SELF <= other_product_version based on their id.
Args:
other_product_version (ProductVersion): The version of comparison
Returns (bool): SELF <= other_product_version based on their id.
"""
return self.version_id <= other_product_version.version_id
def is_after_or_equal_to(self, other_product_version) -> bool:
"""
Returns true if SELF >= other_product_version based on their id.
Args:
other_product_version (ProductVersion): The version of comparison
Returns (bool): SELF >= other_product_version based on their id.
"""
return self.version_id >= other_product_version.version_id