コード例 #1
0
    def test_version(self):
        oommf = oc.OOMMF()
        version = oommf.version(where=None)
        assert isinstance(version, str)
        assert "." in version
        assert version[0].isdigit() and version[-1].isdigit()
        assert 5 < len(version) < 10

        oommf = oc.OOMMF()
        version = oommf.version(where="host")
        assert isinstance(version, str)
        assert "." in version
        assert version[0].isdigit() and version[-1].isdigit()
        assert 5 < len(version) < 10

        oommf = oc.OOMMF()
        version = oommf.version(where="docker")
        assert isinstance(version, str)
        assert "." in version
        assert version[0].isdigit() and version[-1].isdigit()
        assert 5 < len(version) < 10
コード例 #2
0
 def test_call_oommf(self):
     argstr = "+version"
     varname = "OOMMFTCL"
     dockername = "docker"
     raise_exception = True
     dockerimage = "joommf/oommf"
     for where in [None, "host", "docker"]:
         oommf = oc.OOMMF(varname=varname,
                          dockername=dockername,
                          dockerimage=dockerimage,
                          where=where)
         oommf.call(argstr=argstr)
コード例 #3
0
    def test_where_to_run(self):
        # Case 1: choose "host", both working
        where = None
        varname = "OOMMFTCL"
        dockername = "docker"
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        where = oommf._where_to_run(where=where)
        assert where == "host"

        # Case 2: choose "host", only host working
        where = None
        varname = "OOMMFTCL"
        dockername = "wrongdocker"
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        where = oommf._where_to_run(where=where)
        assert where == "host"

        # Case 2: choose "docker", only docker working
        where = None
        varname = "WRONGOMMFPATH"
        dockername = "docker"
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        where = oommf._where_to_run(where=where)
        assert where == "docker"
コード例 #4
0
ファイル: driver.py プロジェクト: takluyver/oommfc
 def _run_simulator(self, system):
     miffilename = self._filenames(system)["miffilename"]
     oommf = oc.OOMMF(self.varname, dockerimage=self.dockerimage,
                      where=None)
     oommf.call(argstr=miffilename)
     oommf.kill()
コード例 #5
0
    def test_status(self):
        # Case 1: host True, docker True
        varname = "OOMMFTCL"
        dockername = "docker"
        raise_exception = True
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is True
        assert status["docker"] is True

        # Case 2: host True, docker False
        varname = "OOMMFTCL"
        dockername = "dockerwrongname"
        raise_exception = True
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is True
        assert status["docker"] is False

        # Case 3: host False (wrong varname), docker True
        varname = "OOMMFWRONGVARNAME"
        dockername = "docker"
        raise_exception = True
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is False
        assert status["docker"] is True

        # Case 4: host False (wrong path), docker True
        varname = "OOMMFWRONGPATH"
        dockername = "docker"
        raise_exception = True
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is False
        assert status["docker"] is True

        # Case 5: host False (wrong path), docker False, no exception
        varname = "WRONGWRONGWRONG"
        dockername = "dockerwrong"
        raise_exception = False
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is False
        assert status["docker"] is False

        # Case 6: host False (wrong path), docker False, raise exception
        varname = "WRONGWRONGWRONG"
        dockername = "dockerwrong"
        raise_exception = True
        with pytest.raises(EnvironmentError):
            oommf = oc.OOMMF(varname=varname, dockername=dockername)
            status = oommf.status(raise_exception=raise_exception,
                                  verbose=True)

        # Case 7: host False (wrong file), docker False, no exception
        varname = "OOMMFWRONGFILE"
        dockername = "dockerwrong"
        raise_exception = False
        oommf = oc.OOMMF(varname=varname, dockername=dockername)
        status = oommf.status(raise_exception=raise_exception, verbose=True)
        assert isinstance(status, dict)
        assert status["host"] is False
        assert status["docker"] is False