Ejemplo n.º 1
0
    def test_works_online(self):
        df, filename = nomenclature.CGN_finder("3SN6", )

        assert isinstance(df, DataFrame)
        assert isinstance(filename, str)
        assert "http" in filename
        _np.testing.assert_array_equal(list(df.keys()),
                                       ["CGN", "Sort number", "3SN6"])
Ejemplo n.º 2
0
 def test_works_local_does_not_overwrite(self):
     with _TDir(suffix="_mdciao_test") as tdir:
         infile = test_filenames.CGN_3SN6
         copy(infile, tdir)
         with pytest.raises(FileExistsError):
             nomenclature.CGN_finder("3SN6",
                                     try_web_lookup=False,
                                     local_path=tdir,
                                     write_to_disk=True)
Ejemplo n.º 3
0
    def test_works_locally(self):
        df, filename = nomenclature.CGN_finder(
            "3SN6",
            try_web_lookup=False,
            local_path=test_filenames.nomenclature_path)

        assert isinstance(df, DataFrame)
        assert isinstance(filename, str)
        _np.testing.assert_array_equal(list(df.keys()),
                                       ["CGN", "Sort number", "3SN6"])
Ejemplo n.º 4
0
    def test_works_online_and_writes_to_disk_ascii(self):
        with _TDir(suffix="_mdciao_test") as tdir:
            df, filename = nomenclature.CGN_finder("3SN6",
                                                   local_path=tdir,
                                                   format="%s.txt",
                                                   write_to_disk=True)

            assert isinstance(df, DataFrame)
            assert isinstance(filename, str)
            assert "http" in filename
            _np.testing.assert_array_equal(list(df.keys()),
                                           ["CGN", "Sort number", "3SN6"])
            assert path.exists(path.join(tdir, "3SN6.txt"))
Ejemplo n.º 5
0
 def test_not_find_online_but_no_raise(self):
     df, filename = nomenclature.CGN_finder("3SNw", dont_fail=True)
     assert df is None
     assert isinstance(filename, str)
     assert "www" in filename
Ejemplo n.º 6
0
 def test_raises_not_find_online(self):
     with pytest.raises(HTTPError):
         nomenclature.CGN_finder("3SNw", )
Ejemplo n.º 7
0
 def test_not_find_locally_but_no_fail(self):
     DF, filename = nomenclature.CGN_finder("3SN6",
                                            try_web_lookup=False,
                                            dont_fail=True)
     assert DF is None
     assert isinstance(filename, str)
Ejemplo n.º 8
0
 def test_raises_not_find_locally(self):
     with pytest.raises(FileNotFoundError):
         nomenclature.CGN_finder("3SN6", try_web_lookup=False)