Skip to content
Snippets Groups Projects
Commit a06f6d09 authored by lukas leufen's avatar lukas leufen
Browse files

adjusted tests

parent 1d45bfff
Branches
Tags
2 merge requests!12Experiment Setup finished,!11finish run script creation, /close #11
Pipeline #25876 passed
......@@ -130,7 +130,7 @@ class TimeTracking(object):
def prepare_host():
hostname = socket.gethostname()
user = os.getlogin()
if hostname == 'ZAM144': # pragma: no branch
if hostname == 'ZAM144':
path = f'/home/{user}/Data/toar_daily/'
elif hostname == 'zam347':
path = f'/home/{user}/Data/toar_daily/'
......
......@@ -140,12 +140,20 @@ class TestTimeTracking:
class TestPrepareHost:
@mock.patch("socket.gethostname", return_value="linux-gzsx")
@mock.patch("socket.gethostname", side_effect=["linux-gzsx", "ZAM144", "zam347", "jrtest", "jwtest"])
@mock.patch("os.getlogin", return_value="testUser")
@mock.patch("os.path.exists", return_value=True)
def test_prepare_host(self, mock_host, mock_user, mock_path):
path = prepare_host()
assert path == "/home/testUser/machinelearningtools"
path = prepare_host()
assert path == "/home/testUser/Data/toar_daily/"
path = prepare_host()
assert path == "/home/testUser/Data/toar_daily/"
path = prepare_host()
assert path == "/p/project/cjjsc42/testUser/DATA/toar_daily/"
path = prepare_host()
assert path == "/p/home/jusers/testUser/juwels/intelliaq/DATA/toar_daily/"
@mock.patch("socket.gethostname", return_value="NotExistingHostName")
@mock.patch("os.getlogin", return_value="zombie21")
......@@ -167,7 +175,7 @@ class TestSetExperimentName:
assert exp_path == os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ""))
exp_name, exp_path = set_experiment_name(experiment_date="2019-11-14", experiment_path="./test2")
assert exp_name == "2019-11-14_network/"
assert exp_path == os.path.abspath(os.path.join(os.path.dirname(__file__), "test2"))
assert exp_path == os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "test2"))
def test_set_experiment_from_sys(self):
exp_name, _ = set_experiment_name(experiment_date="2019-11-14")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment