Skip to content

Commit

Permalink
fix PR review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejoigny-ledger committed May 30, 2024
1 parent 49c1dda commit ee1500f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List
import re
import pytest

# pylint: disable=wildcard-import, unused-wildcard-import
Expand All @@ -8,7 +10,7 @@ def check_accepted_version(monero, valid_version: bytes):
major, minor, patch = monero.reset_and_get_version(
monero_client_version=valid_version
) # type: int, int, int
assert (major, minor, patch) == (2, 0, 0) # version of the Monero app
_verify_version(f"{major}.{minor}.{patch}")


def check_refused_version(monero, invalid_version: bytes):
Expand All @@ -25,3 +27,33 @@ def test_version(monero):
check_accepted_version(monero, b"0.18.9.0")
check_accepted_version(monero, b"0.18.18.0")


def _verify_version(version: str) -> None:
"""Verify the app version, based on defines in Makefile
Args:
Version (str): Version to be checked
"""

vers_dict = {}
vers_str = ""
lines = _read_makefile()
version_re = re.compile(r"^APPVERSION_(?P<part>\w)\s?=\s?(?P<val>\d*)", re.I)
for line in lines:
info = version_re.match(line)
if info:
dinfo = info.groupdict()
vers_dict[dinfo["part"]] = dinfo["val"]
try:
vers_str = f"{vers_dict['M']}.{vers_dict['N']}.{vers_dict['P']}"
except KeyError:
pass
assert version == vers_str


def _read_makefile() -> List[str]:
"""Read lines from the parent Makefile """

with open("Makefile", "r", encoding="utf-8") as f_p:
lines = f_p.readlines()
return lines

0 comments on commit ee1500f

Please sign in to comment.