Skip to content

Commit

Permalink
fix utils tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parkererickson-tg committed Oct 1, 2024
1 parent 918f1fb commit dff6558
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions tests/test_pyTigerGraphUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import unittest
from datetime import datetime

from pyTigerGraph.common.util import _safe_char

from pyTigerGraphUnitTest import make_connection

from pyTigerGraph.common.exception import TigerGraphException
Expand All @@ -13,21 +15,21 @@ def setUpClass(cls):
cls.conn = make_connection(graphname="tests")

def test_01_safeChar(self):
res = self.conn._safe_char(" _space")
res = _safe_char(" _space")
self.assertEqual("%20_space", res)
res = self.conn._safe_char("/_slash")
res = _safe_char("/_slash")
self.assertEqual("%2F_slash", res)
res = self.conn._safe_char("ñ_LATIN_SMALL_LETTER_N_WITH_TILDE")
res = _safe_char("ñ_LATIN_SMALL_LETTER_N_WITH_TILDE")
self.assertEqual(res, '%C3%B1_LATIN_SMALL_LETTER_N_WITH_TILDE')
res = self.conn._safe_char(12345)
res = _safe_char(12345)
self.assertEqual("12345", res)
res = self.conn._safe_char(12.345)
res = _safe_char(12.345)
self.assertEqual("12.345", res)
now = datetime.now()
res = self.conn._safe_char(now)
res = _safe_char(now)
exp = str(now).replace(" ", "%20").replace(":", "%3A")
self.assertEqual(exp, res)
res = self.conn._safe_char(True)
res = _safe_char(True)
self.assertEqual("True", res)

def test_02_echo(self):
Expand Down Expand Up @@ -55,7 +57,7 @@ def test_05_ping(self):
self.assertEqual(res["message"], "pong")

def test_06_getSystemMetrics(self):
if self.conn._versionGreaterThan4_0():
if self.conn._version_greater_than_4_0():
res = self.conn.getSystemMetrics(what="cpu-memory")
self.assertIn("CPUMemoryMetrics", res)
res = self.conn.getSystemMetrics(what="diskspace")
Expand Down
18 changes: 10 additions & 8 deletions tests/test_pyTigerGraphUtilsAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import unittest
from datetime import datetime

from pyTigerGraph.common.util import _safe_char

from pyTigerGraphUnitTestAsync import make_connection

from pyTigerGraph.common.exception import TigerGraphException
Expand All @@ -12,21 +14,21 @@ async def asyncSetUp(self):
self.conn = await make_connection()

def test_01_safeChar(self):
res = self.conn._safeChar(" _space")
res = _safe_char(" _space")
self.assertEqual("%20_space", res)
res = self.conn._safeChar("/_slash")
res = _safe_char("/_slash")
self.assertEqual("%2F_slash", res)
res = self.conn._safeChar("ñ_LATIN_SMALL_LETTER_N_WITH_TILDE")
res = _safe_char("ñ_LATIN_SMALL_LETTER_N_WITH_TILDE")
self.assertEqual(res, '%C3%B1_LATIN_SMALL_LETTER_N_WITH_TILDE')
res = self.conn._safeChar(12345)
res = _safe_char(12345)
self.assertEqual("12345", res)
res = self.conn._safeChar(12.345)
res = _safe_char(12.345)
self.assertEqual("12.345", res)
now = datetime.now()
res = self.conn._safeChar(now)
res = _safe_char(now)
exp = str(now).replace(" ", "%20").replace(":", "%3A")
self.assertEqual(exp, res)
res = self.conn._safeChar(True)
res = _safe_char(True)
self.assertEqual("True", res)

async def test_02_echo(self):
Expand Down Expand Up @@ -54,7 +56,7 @@ async def test_05_ping(self):
self.assertEqual(res["message"], "pong")

async def test_06_getSystemMetrics(self):
if await self.conn._versionGreaterThan4_0():
if await self.conn._version_greater_than_4_0():
res = await self.conn.getSystemMetrics(what="cpu-memory")
self.assertIn("CPUMemoryMetrics", res)
res = await self.conn.getSystemMetrics(what="diskspace")
Expand Down

0 comments on commit dff6558

Please sign in to comment.