Merge pull request #17 from HideyoshiNakazone/chore/switches-to-ruff
chore: better project structure
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from diceplayer.shared.utils.logger import Logger
|
from diceplayer.utils import Logger
|
||||||
|
|
||||||
from importlib import metadata
|
from importlib import metadata
|
||||||
|
|
||||||
|
|||||||
6
diceplayer/environment/__init__.py
Normal file
6
diceplayer/environment/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from .atom import Atom
|
||||||
|
from .molecule import Molecule
|
||||||
|
from .system import System
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["Atom", "Molecule", "System"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from diceplayer.shared.utils.ptable import atommass
|
from diceplayer.utils.ptable import atommass
|
||||||
|
|
||||||
|
|
||||||
class Atom:
|
class Atom:
|
||||||
@@ -7,9 +7,9 @@ if TYPE_CHECKING:
|
|||||||
from nptyping import Float, NDArray, Shape
|
from nptyping import Float, NDArray, Shape
|
||||||
|
|
||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment.atom import Atom
|
||||||
from diceplayer.shared.utils.misc import BOHR2ANG
|
from diceplayer.utils.misc import BOHR2ANG
|
||||||
from diceplayer.shared.utils.ptable import ghost_number
|
from diceplayer.utils.ptable import ghost_number
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.linalg import linalg
|
from numpy.linalg import linalg
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.shared.environment.molecule import Molecule
|
from diceplayer.environment.molecule import Molecule
|
||||||
from diceplayer.shared.utils.misc import BOHR2ANG
|
from diceplayer.utils.misc import BOHR2ANG
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy import linalg
|
from numpy import linalg
|
||||||
6
diceplayer/interface/__init__.py
Normal file
6
diceplayer/interface/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from .__interface import Interface
|
||||||
|
from .dice_interface import DiceInterface
|
||||||
|
from .gaussian_interface import GaussianInterface
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["Interface", "DiceInterface", "GaussianInterface"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.system import System
|
from diceplayer.environment.system import System
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
@@ -2,8 +2,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.system import System
|
from diceplayer.environment.system import System
|
||||||
from diceplayer.shared.interface import Interface
|
from diceplayer.interface import Interface
|
||||||
|
|
||||||
from setproctitle import setproctitle
|
from setproctitle import setproctitle
|
||||||
from typing_extensions import Final, TextIO
|
from typing_extensions import Final, TextIO
|
||||||
@@ -2,12 +2,12 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment.atom import Atom
|
||||||
from diceplayer.shared.environment.molecule import Molecule
|
from diceplayer.environment.molecule import Molecule
|
||||||
from diceplayer.shared.environment.system import System
|
from diceplayer.environment.system import System
|
||||||
from diceplayer.shared.interface import Interface
|
from diceplayer.interface import Interface
|
||||||
from diceplayer.shared.utils.misc import date_time
|
from diceplayer.utils.misc import date_time
|
||||||
from diceplayer.shared.utils.ptable import atomsymb
|
from diceplayer.utils.ptable import atomsymb
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from nptyping import NDArray
|
from nptyping import NDArray
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
from diceplayer import VERSION, logger
|
from diceplayer import VERSION, logger
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment import Atom, Molecule, System
|
||||||
from diceplayer.shared.environment.molecule import Molecule
|
from diceplayer.interface import DiceInterface, GaussianInterface
|
||||||
from diceplayer.shared.environment.system import System
|
from diceplayer.utils import atomsymb, weekday_date_time
|
||||||
from diceplayer.shared.interface.dice_interface import DiceInterface
|
|
||||||
from diceplayer.shared.interface.gaussian_interface import GaussianInterface
|
|
||||||
from diceplayer.shared.utils.misc import weekday_date_time
|
|
||||||
from diceplayer.shared.utils.ptable import atomsymb
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
from .__interface import Interface
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["Interface"]
|
|
||||||
22
diceplayer/utils/__init__.py
Normal file
22
diceplayer/utils/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from .logger import Logger, valid_logger
|
||||||
|
from .misc import (
|
||||||
|
compress_files_1mb,
|
||||||
|
date_time,
|
||||||
|
make_qm_dir,
|
||||||
|
make_step_dir,
|
||||||
|
weekday_date_time,
|
||||||
|
)
|
||||||
|
from .ptable import atommass, atomsymb
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"Logger",
|
||||||
|
"valid_logger",
|
||||||
|
"atomsymb",
|
||||||
|
"atommass",
|
||||||
|
"weekday_date_time",
|
||||||
|
"date_time",
|
||||||
|
"compress_files_1mb",
|
||||||
|
"make_step_dir",
|
||||||
|
"make_qm_dir",
|
||||||
|
]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment import Atom
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment import Atom, Molecule
|
||||||
from diceplayer.shared.environment.molecule import Molecule
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import numpy.testing as npt
|
import numpy.testing as npt
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from diceplayer.shared.environment.molecule import Molecule
|
from diceplayer.environment import Molecule, System
|
||||||
from diceplayer.shared.environment.system import System
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.atom import Atom
|
from diceplayer.environment import Atom, Molecule, System
|
||||||
from diceplayer.shared.environment.molecule import Molecule
|
from diceplayer.interface import DiceInterface
|
||||||
from diceplayer.shared.environment.system import System
|
|
||||||
from diceplayer.shared.interface.dice_interface import DiceInterface
|
|
||||||
from tests.mocks.mock_inputs import get_config_example
|
from tests.mocks.mock_inputs import get_config_example
|
||||||
from tests.mocks.mock_proc import MockConnection, MockProc
|
from tests.mocks.mock_proc import MockConnection, MockProc
|
||||||
|
|
||||||
@@ -51,18 +49,16 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertFalse(hasattr(dice, "step"))
|
self.assertFalse(hasattr(dice, "step"))
|
||||||
self.assertFalse(hasattr(dice, "system"))
|
self.assertFalse(hasattr(dice, "system"))
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.Process", MockProc())
|
@mock.patch("diceplayer.interface.dice_interface.Process", MockProc())
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.connection", MockConnection)
|
@mock.patch("diceplayer.interface.dice_interface.connection", MockConnection)
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
dice = DiceInterface()
|
dice = DiceInterface()
|
||||||
dice.configure(self.config, System())
|
dice.configure(self.config, System())
|
||||||
|
|
||||||
dice.start(1)
|
dice.start(1)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.connection", MockConnection)
|
@mock.patch("diceplayer.interface.dice_interface.connection", MockConnection)
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Process", MockProc(exitcode=1))
|
||||||
"diceplayer.shared.interface.dice_interface.Process", MockProc(exitcode=1)
|
|
||||||
)
|
|
||||||
def test_start_with_process_error(self):
|
def test_start_with_process_error(self):
|
||||||
dice = DiceInterface()
|
dice = DiceInterface()
|
||||||
dice.configure(self.config, System())
|
dice.configure(self.config, System())
|
||||||
@@ -76,13 +72,9 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
dice._simulation_process(1, 1)
|
dice._simulation_process(1, 1)
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.DiceInterface._make_proc_dir")
|
||||||
"diceplayer.shared.interface.dice_interface.DiceInterface._make_proc_dir"
|
@mock.patch("diceplayer.interface.dice_interface.DiceInterface._make_dice_inputs")
|
||||||
)
|
@mock.patch("diceplayer.interface.dice_interface.DiceInterface._run_dice")
|
||||||
@mock.patch(
|
|
||||||
"diceplayer.shared.interface.dice_interface.DiceInterface._make_dice_inputs"
|
|
||||||
)
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.DiceInterface._run_dice")
|
|
||||||
def test_simulation_process(
|
def test_simulation_process(
|
||||||
self, mock_run_dice, mock_make_dice_inputs, mock_make_proc_dir
|
self, mock_run_dice, mock_make_dice_inputs, mock_make_proc_dir
|
||||||
):
|
):
|
||||||
@@ -94,8 +86,8 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertTrue(dice._make_dice_inputs.called)
|
self.assertTrue(dice._make_dice_inputs.called)
|
||||||
self.assertTrue(dice._run_dice.called)
|
self.assertTrue(dice._run_dice.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.Path.mkdir")
|
@mock.patch("diceplayer.interface.dice_interface.Path.mkdir")
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.Path.exists")
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists")
|
||||||
def test_make_proc_dir_if_simdir_exists(self, mock_path_exists, mock_path_mkdir):
|
def test_make_proc_dir_if_simdir_exists(self, mock_path_exists, mock_path_mkdir):
|
||||||
dice = DiceInterface()
|
dice = DiceInterface()
|
||||||
dice.configure(self.config, System())
|
dice.configure(self.config, System())
|
||||||
@@ -106,8 +98,8 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(mock_path_mkdir.call_count, 2)
|
self.assertEqual(mock_path_mkdir.call_count, 2)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.Path.mkdir")
|
@mock.patch("diceplayer.interface.dice_interface.Path.mkdir")
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.Path.exists")
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists")
|
||||||
def test_make_proc_dir_if_simdir_doesnt_exists(
|
def test_make_proc_dir_if_simdir_doesnt_exists(
|
||||||
self, mock_path_exists, mock_path_mkdir
|
self, mock_path_exists, mock_path_mkdir
|
||||||
):
|
):
|
||||||
@@ -155,9 +147,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertFalse(dice._make_npt_eq.called)
|
self.assertFalse(dice._make_npt_eq.called)
|
||||||
|
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="test")
|
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="test")
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists", return_value=True)
|
||||||
"diceplayer.shared.interface.dice_interface.Path.exists", return_value=True
|
|
||||||
)
|
|
||||||
def test_make_dice_inputs_nstep_len_two_with_randoninit_first_cycle_two(
|
def test_make_dice_inputs_nstep_len_two_with_randoninit_first_cycle_two(
|
||||||
self, mock_path_exists, mock_open
|
self, mock_path_exists, mock_open
|
||||||
):
|
):
|
||||||
@@ -189,9 +179,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertFalse(dice._make_npt_ter.called)
|
self.assertFalse(dice._make_npt_ter.called)
|
||||||
self.assertFalse(dice._make_npt_eq.called)
|
self.assertFalse(dice._make_npt_eq.called)
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists", return_value=False)
|
||||||
"diceplayer.shared.interface.dice_interface.Path.exists", return_value=False
|
|
||||||
)
|
|
||||||
def test_make_dice_inputs_raises_exception_on_last_not_found(
|
def test_make_dice_inputs_raises_exception_on_last_not_found(
|
||||||
self, mock_path_exists
|
self, mock_path_exists
|
||||||
):
|
):
|
||||||
@@ -240,11 +228,9 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertTrue(dice._make_npt_ter.called)
|
self.assertTrue(dice._make_npt_ter.called)
|
||||||
self.assertTrue(dice._make_npt_eq.called)
|
self.assertTrue(dice._make_npt_eq.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.os")
|
@mock.patch("diceplayer.interface.dice_interface.os")
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.shutil")
|
@mock.patch("diceplayer.interface.dice_interface.shutil")
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists", return_value=True)
|
||||||
"diceplayer.shared.interface.dice_interface.Path.exists", return_value=True
|
|
||||||
)
|
|
||||||
def test_run_dice_on_first_cycle_run_successful(
|
def test_run_dice_on_first_cycle_run_successful(
|
||||||
self, mock_path_exists, mock_shutils, mock_os
|
self, mock_path_exists, mock_shutils, mock_os
|
||||||
):
|
):
|
||||||
@@ -278,11 +264,9 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(dice.run_dice_file.call_count, 2)
|
self.assertEqual(dice.run_dice_file.call_count, 2)
|
||||||
self.assertTrue(mock_shutils.copy.called)
|
self.assertTrue(mock_shutils.copy.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.os")
|
@mock.patch("diceplayer.interface.dice_interface.os")
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.shutil")
|
@mock.patch("diceplayer.interface.dice_interface.shutil")
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists", return_value=True)
|
||||||
"diceplayer.shared.interface.dice_interface.Path.exists", return_value=True
|
|
||||||
)
|
|
||||||
def test_run_dice_on_second_cycle_run_successful(
|
def test_run_dice_on_second_cycle_run_successful(
|
||||||
self, mock_path_exists, mock_shutils, mock_os
|
self, mock_path_exists, mock_shutils, mock_os
|
||||||
):
|
):
|
||||||
@@ -312,11 +296,9 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(dice.run_dice_file.call_count, 2)
|
self.assertEqual(dice.run_dice_file.call_count, 2)
|
||||||
self.assertTrue(mock_shutils.copy.called)
|
self.assertTrue(mock_shutils.copy.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.os")
|
@mock.patch("diceplayer.interface.dice_interface.os")
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.shutil")
|
@mock.patch("diceplayer.interface.dice_interface.shutil")
|
||||||
@mock.patch(
|
@mock.patch("diceplayer.interface.dice_interface.Path.exists", return_value=False)
|
||||||
"diceplayer.shared.interface.dice_interface.Path.exists", return_value=False
|
|
||||||
)
|
|
||||||
def test_run_dice_raises_filenotfound_on_invalid_file(
|
def test_run_dice_raises_filenotfound_on_invalid_file(
|
||||||
self, mock_path_exists, mock_shutils, mock_os
|
self, mock_path_exists, mock_shutils, mock_os
|
||||||
):
|
):
|
||||||
@@ -424,7 +406,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(density, 85.35451545000001)
|
self.assertEqual(density, 85.35451545000001)
|
||||||
|
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.random")
|
@mock.patch("diceplayer.interface.dice_interface.random")
|
||||||
def test_make_nvt_ter(self, mock_random, mock_open):
|
def test_make_nvt_ter(self, mock_random, mock_open):
|
||||||
mock_random.random.return_value = 1
|
mock_random.random.return_value = 1
|
||||||
|
|
||||||
@@ -461,7 +443,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(lines, expected_lines)
|
self.assertEqual(lines, expected_lines)
|
||||||
|
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.random")
|
@mock.patch("diceplayer.interface.dice_interface.random")
|
||||||
def test_make_nvt_eq(self, mock_random, mock_open):
|
def test_make_nvt_eq(self, mock_random, mock_open):
|
||||||
mock_random.random.return_value = 1
|
mock_random.random.return_value = 1
|
||||||
|
|
||||||
@@ -497,7 +479,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(lines, expected_lines)
|
self.assertEqual(lines, expected_lines)
|
||||||
|
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.random")
|
@mock.patch("diceplayer.interface.dice_interface.random")
|
||||||
def test_make_npt_ter(self, mock_random, mock_open):
|
def test_make_npt_ter(self, mock_random, mock_open):
|
||||||
mock_random.random.return_value = 1
|
mock_random.random.return_value = 1
|
||||||
|
|
||||||
@@ -533,7 +515,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertEqual(lines, expected_lines)
|
self.assertEqual(lines, expected_lines)
|
||||||
|
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
@mock.patch("builtins.open", new_callable=mock.mock_open)
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.random")
|
@mock.patch("diceplayer.interface.dice_interface.random")
|
||||||
def test_make_npt_eq(self, mock_random, mock_open):
|
def test_make_npt_eq(self, mock_random, mock_open):
|
||||||
mock_random.random.return_value = 1
|
mock_random.random.return_value = 1
|
||||||
|
|
||||||
@@ -612,7 +594,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(lines, expected_lines)
|
self.assertEqual(lines, expected_lines)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.subprocess")
|
@mock.patch("diceplayer.interface.dice_interface.subprocess")
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
"builtins.open",
|
"builtins.open",
|
||||||
new_callable=mock.mock_open,
|
new_callable=mock.mock_open,
|
||||||
@@ -628,7 +610,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
self.assertTrue(mock_subprocess.call.called)
|
self.assertTrue(mock_subprocess.call.called)
|
||||||
self.assertTrue(mock_open.called)
|
self.assertTrue(mock_open.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.subprocess")
|
@mock.patch("diceplayer.interface.dice_interface.subprocess")
|
||||||
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="Error\nBLABLA")
|
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="Error\nBLABLA")
|
||||||
def test_run_dice_file_raises_runtime_error_on_dice_file(
|
def test_run_dice_file_raises_runtime_error_on_dice_file(
|
||||||
self, mock_open, mock_subprocess
|
self, mock_open, mock_subprocess
|
||||||
@@ -640,7 +622,7 @@ class TestDiceInterface(unittest.TestCase):
|
|||||||
with self.assertRaises(RuntimeError):
|
with self.assertRaises(RuntimeError):
|
||||||
dice.run_dice_file(1, 1, "test")
|
dice.run_dice_file(1, 1, "test")
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.dice_interface.subprocess")
|
@mock.patch("diceplayer.interface.dice_interface.subprocess")
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
"builtins.open",
|
"builtins.open",
|
||||||
new_callable=mock.mock_open,
|
new_callable=mock.mock_open,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from diceplayer import logger
|
from diceplayer import logger
|
||||||
from diceplayer.config.player_config import PlayerConfig
|
from diceplayer.config.player_config import PlayerConfig
|
||||||
from diceplayer.shared.environment.system import System
|
from diceplayer.environment import System
|
||||||
from diceplayer.shared.interface.gaussian_interface import GaussianInterface
|
from diceplayer.interface import GaussianInterface
|
||||||
from tests.mocks.mock_inputs import get_config_example
|
from tests.mocks.mock_inputs import get_config_example
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
@@ -46,8 +46,8 @@ class TestGaussianInterface(unittest.TestCase):
|
|||||||
self.assertFalse(hasattr(gaussian_interface, "step"))
|
self.assertFalse(hasattr(gaussian_interface, "step"))
|
||||||
self.assertFalse(hasattr(gaussian_interface, "system"))
|
self.assertFalse(hasattr(gaussian_interface, "system"))
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.Path.mkdir")
|
@mock.patch("diceplayer.interface.gaussian_interface.Path.mkdir")
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.Path.exists")
|
@mock.patch("diceplayer.interface.gaussian_interface.Path.exists")
|
||||||
def test_make_qm_dir(self, mock_exists, mock_mkdir):
|
def test_make_qm_dir(self, mock_exists, mock_mkdir):
|
||||||
mock_exists.return_value = False
|
mock_exists.return_value = False
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ class TestGaussianInterface(unittest.TestCase):
|
|||||||
mock_exists.assert_called_once()
|
mock_exists.assert_called_once()
|
||||||
mock_mkdir.assert_called_once()
|
mock_mkdir.assert_called_once()
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.shutil.copy")
|
@mock.patch("diceplayer.interface.gaussian_interface.shutil.copy")
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.Path.exists")
|
@mock.patch("diceplayer.interface.gaussian_interface.Path.exists")
|
||||||
def test_copy_chk_file_from_previous_step(self, mock_exists, mock_copy):
|
def test_copy_chk_file_from_previous_step(self, mock_exists, mock_copy):
|
||||||
gaussian_interface = GaussianInterface()
|
gaussian_interface = GaussianInterface()
|
||||||
gaussian_interface.configure(self.config, System())
|
gaussian_interface.configure(self.config, System())
|
||||||
@@ -72,8 +72,8 @@ class TestGaussianInterface(unittest.TestCase):
|
|||||||
self.assertTrue(mock_exists.called)
|
self.assertTrue(mock_exists.called)
|
||||||
self.assertTrue(mock_copy.called)
|
self.assertTrue(mock_copy.called)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.shutil.copy")
|
@mock.patch("diceplayer.interface.gaussian_interface.shutil.copy")
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.Path.exists")
|
@mock.patch("diceplayer.interface.gaussian_interface.Path.exists")
|
||||||
def test_copy_chk_file_from_previous_step_no_previous_step(
|
def test_copy_chk_file_from_previous_step_no_previous_step(
|
||||||
self, mock_exists, mock_copy
|
self, mock_exists, mock_copy
|
||||||
):
|
):
|
||||||
@@ -85,8 +85,8 @@ class TestGaussianInterface(unittest.TestCase):
|
|||||||
with self.assertRaises(FileNotFoundError):
|
with self.assertRaises(FileNotFoundError):
|
||||||
gaussian_interface._copy_chk_file_from_previous_step(2)
|
gaussian_interface._copy_chk_file_from_previous_step(2)
|
||||||
|
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.shutil.copy")
|
@mock.patch("diceplayer.interface.gaussian_interface.shutil.copy")
|
||||||
@mock.patch("diceplayer.shared.interface.gaussian_interface.Path.exists")
|
@mock.patch("diceplayer.interface.gaussian_interface.Path.exists")
|
||||||
def test_copy_chk_file_from_previous_step_current_exists(
|
def test_copy_chk_file_from_previous_step_current_exists(
|
||||||
self, mock_exists, mock_copy
|
self, mock_exists, mock_copy
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from diceplayer.shared.utils.logger import Logger, valid_logger
|
from diceplayer.utils import Logger, valid_logger
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
@@ -53,8 +53,8 @@ class TestLogger(unittest.TestCase):
|
|||||||
self.assertEqual(logger._logger.name, "test")
|
self.assertEqual(logger._logger.name, "test")
|
||||||
|
|
||||||
@mock.patch("builtins.open", mock.mock_open())
|
@mock.patch("builtins.open", mock.mock_open())
|
||||||
@mock.patch("diceplayer.shared.utils.logger.Path.exists")
|
@mock.patch("diceplayer.utils.logger.Path.exists")
|
||||||
@mock.patch("diceplayer.shared.utils.logger.Path.rename")
|
@mock.patch("diceplayer.utils.logger.Path.rename")
|
||||||
def test_set_logger_if_file_exists(self, mock_rename, mock_exists):
|
def test_set_logger_if_file_exists(self, mock_rename, mock_exists):
|
||||||
logger = Logger("test")
|
logger = Logger("test")
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ class TestLogger(unittest.TestCase):
|
|||||||
self.assertEqual(logger._logger.name, "test")
|
self.assertEqual(logger._logger.name, "test")
|
||||||
|
|
||||||
@mock.patch("builtins.open", mock.mock_open())
|
@mock.patch("builtins.open", mock.mock_open())
|
||||||
@mock.patch("diceplayer.shared.utils.logger.Path.exists")
|
@mock.patch("diceplayer.utils.logger.Path.exists")
|
||||||
@mock.patch("diceplayer.shared.utils.logger.Path.rename")
|
@mock.patch("diceplayer.utils.logger.Path.rename")
|
||||||
def test_set_logger_if_file_not_exists(self, mock_rename, mock_exists):
|
def test_set_logger_if_file_not_exists(self, mock_rename, mock_exists):
|
||||||
logger = Logger("test")
|
logger = Logger("test")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user