Skip to content

Commit

Permalink
#3 Add g2diagnostic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Dec 14, 2023
1 parent 5d4ee50 commit 7262f37
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 11 deletions.
10 changes: 5 additions & 5 deletions tests/g2config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def g2config_fixture() -> g2config_abstract.G2ConfigAbstract:

class G2ConfigTest(g2config_abstract.G2ConfigAbstract):
"""
G2 config module access library over gRPC.
G2 config module access library.
"""

# -------------------------------------------------------------------------
Expand All @@ -50,7 +50,7 @@ def add_data_source(
return ""

def close(self, config_handle: int, *args: Any, **kwargs: Any) -> None:
"""Null method"""
"""None"""

def create(self, *args: Any, **kwargs: Any) -> int:
return 0
Expand All @@ -62,10 +62,10 @@ def delete_data_source(
*args: Any,
**kwargs: Any,
) -> None:
"""Null method"""
"""None"""

def destroy(self, *args: Any, **kwargs: Any) -> None:
"""Null method"""
"""None"""

def init(
self,
Expand All @@ -74,7 +74,7 @@ def init(
verbose_logging: int = 0,
**kwargs: Any,
) -> None:
"""Null method"""
"""None"""

def list_data_sources(self, config_handle: int, *args: Any, **kwargs: Any) -> str:
return ""
Expand Down
12 changes: 6 additions & 6 deletions tests/g2configmgr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


@pytest.fixture(name="g2_configmgr", scope="module") # type: ignore[misc]
def g2config_fixture() -> g2configmgr_abstract.G2ConfigMgrAbstract:
def g2configmgr_fixture() -> g2configmgr_abstract.G2ConfigMgrAbstract:
"""
Object under test.
"""
Expand All @@ -33,7 +33,7 @@ def g2config_fixture() -> g2configmgr_abstract.G2ConfigMgrAbstract:

class G2ConfigMgrTest(g2configmgr_abstract.G2ConfigMgrAbstract):
"""
G2 config module access library over gRPC.
G2 configmgr module access library.
"""

# -------------------------------------------------------------------------
Expand All @@ -50,7 +50,7 @@ def add_config(
return 0

def destroy(self, *args: Any, **kwargs: Any) -> None:
"""Null method"""
"""None"""

def get_config(self, config_id: int, *args: Any, **kwargs: Any) -> str:
return ""
Expand All @@ -68,15 +68,15 @@ def init(
verbose_logging: int = 0,
**kwargs: Any,
) -> None:
"""Null method"""
"""None"""

def replace_default_config_id(
self, old_config_id: int, new_config_id: int, *args: Any, **kwargs: Any
) -> None:
"""Null method"""
"""None"""

def set_default_config_id(self, config_id: int, *args: Any, **kwargs: Any) -> None:
"""Null method"""
"""None"""


# -----------------------------------------------------------------------------
Expand Down
159 changes: 159 additions & 0 deletions tests/g2diagnostic_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#! /usr/bin/env python3

"""
TODO: g2diagnostic_test.py
"""

# pylint: disable=E1101

from typing import Any, Dict, Union

import pytest

from senzing_abstract import g2diagnostic_abstract

# -----------------------------------------------------------------------------
# G2Config fixtures
# -----------------------------------------------------------------------------


@pytest.fixture(name="g2_diagnostic", scope="module") # type: ignore[misc]
def g2diagnostic_fixture() -> g2diagnostic_abstract.G2DiagnosticAbstract:
"""
Object under test.
"""

return G2DiagnosticTest()


# -----------------------------------------------------------------------------
# G2ConfigTest class
# -----------------------------------------------------------------------------


class G2DiagnosticTest(g2diagnostic_abstract.G2DiagnosticAbstract):
"""
G2 diagnostic module access library.
"""

# -------------------------------------------------------------------------
# G2Diagnostic methods
# -------------------------------------------------------------------------

def check_db_perf(self, seconds_to_run: int, *args: Any, **kwargs: Any) -> str:
return ""

def destroy(self, *args: Any, **kwargs: Any) -> None:
"""None"""

def get_available_memory(self, *args: Any, **kwargs: Any) -> int:
return 0

def get_db_info(self, *args: Any, **kwargs: Any) -> str:
return ""

def get_logical_cores(self, *args: Any, **kwargs: Any) -> int:
return 0

def get_physical_cores(self, *args: Any, **kwargs: Any) -> int:
return 0

def get_total_system_memory(self, *args: Any, **kwargs: Any) -> int:
return 0

def init(
self,
module_name: str,
ini_params: Union[str, Dict[Any, Any]],
verbose_logging: int = 0,
**kwargs: Any,
) -> None:
"""None"""

def init_with_config_id(
self,
module_name: str,
ini_params: Union[str, Dict[Any, Any]],
init_config_id: int,
verbose_logging: int = 0,
**kwargs: Any,
) -> None:
"""None"""

def reinit(self, init_config_id: int, *args: Any, **kwargs: Any) -> None:
"""None"""


# -----------------------------------------------------------------------------
# Test cases
# -----------------------------------------------------------------------------


def test_check_db_perf(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().check_db_perf()."""
g2_diagnostic.check_db_perf(0)


def test_destroy(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().destroy()."""
g2_diagnostic.destroy()


def test_get_available_memory(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().get_available_memory()."""
g2_diagnostic.get_available_memory()


def test_get_db_info(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().get_db_info()."""
g2_diagnostic.get_db_info()


def test_get_logical_cores(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().get_logical_cores()."""
g2_diagnostic.get_logical_cores()


def test_get_physical_cores(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().get_physical_cores()."""
g2_diagnostic.get_physical_cores()


def test_get_total_system_memory(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().get_total_system_memory()."""
g2_diagnostic.get_total_system_memory()


def test_init(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().init()."""
g2_diagnostic.init("", "")


def test_init_with_config_id(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().init_with_config_id()."""
g2_diagnostic.init_with_config_id("", "", 0)


def test_reinit(
g2_diagnostic: g2diagnostic_abstract.G2DiagnosticAbstract,
) -> None:
"""Test G2Config().reinit()."""
g2_diagnostic.reinit(0)

0 comments on commit 7262f37

Please sign in to comment.