Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Sep 11, 2024
1 parent de74293 commit 193ddf2
Show file tree
Hide file tree
Showing 54 changed files with 98 additions and 114 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/run-tests-build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ env:

jobs:
tests:
name: "py_${{ matrix.python-version }}_ert-${{ matrix.ert_version }}_${{ matrix.test_type }}"
name: "py_${{ matrix.python-version }}_${{ matrix.test_type }}"
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.11', '3.12']
os: [ubuntu-22.04]
test_type: ['doc', 'ui-test', 'test', 'integration-test', 'everest-models-test']
ert_version: ['release', 'main']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
23 changes: 1 addition & 22 deletions tests/everest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Callable, Dict, Iterator, Optional, Union

import pytest

from everest.config.control_config import ControlConfig


Expand Down Expand Up @@ -82,25 +83,3 @@ def control_config(
config = deepcopy(control_data_no_variables)
config["variables"] = request.param
return ControlConfig.model_validate(config)


@pytest.fixture(scope="session", autouse=True)
def hide_window(request):
if request.config.getoption("--show-gui"):
yield
return

old_value = os.environ.get("QT_QPA_PLATFORM")
if sys.platform == "darwin":
os.environ["QT_QPA_PLATFORM"] = "offscreen"
else:
os.environ["QT_QPA_PLATFORM"] = "minimal"
yield
if old_value is None:
del os.environ["QT_QPA_PLATFORM"]
else:
os.environ["QT_QPA_PLATFORM"] = old_value


def pytest_addoption(parser):
parser.addoption("--show-gui", action="store_true", default=False)
4 changes: 2 additions & 2 deletions tests/everest/entry_points/test_config_branch_entry.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from os.path import exists
from unittest.mock import PropertyMock, patch

from seba_sqlite.snapshot import SebaSnapshot

from everest.bin.config_branch_script import config_branch_entry
from everest.config import EverestConfig
from everest.config_file_loader import load_yaml
from everest.config_keys import ConfigKeys as CK
from seba_sqlite.snapshot import SebaSnapshot

from tests.everest.utils import relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/entry_points/test_everest_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import PropertyMock, patch

import pytest

from everest.bin.everest_script import everest_entry
from everest.bin.kill_script import kill_entry
from everest.bin.monitor_script import monitor_entry
Expand All @@ -16,7 +17,6 @@
from everest.jobs import shell_commands
from everest.simulator import JOB_SUCCESS
from ieverest.bin.ieverest_script import ieverest_entry

from tests.everest.utils import capture_logger, capture_streams, relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/entry_points/test_everexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import pandas as pd
import pytest

from everest import ConfigKeys as CK
from everest import MetaDataColumnNames as MDCN
from everest.bin.everexport_script import everexport_entry
from everest.bin.utils import ProgressBar
from everest.config import EverestConfig

from tests.everest.utils import (
capture_logger,
create_cached_mocked_test_case,
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/entry_points/test_visualization_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from unittest.mock import PropertyMock, patch

import pytest

from everest.bin.visualization_script import visualization_entry
from everest.config import EverestConfig
from everest.detached import ServerStatus

from tests.everest.utils import capture_streams, relpath

CONFIG_PATH = relpath("..", "..", "examples", "math_func", "config_advanced.yml")
Expand Down
17 changes: 9 additions & 8 deletions tests/everest/functional/test_main_everest_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
from textwrap import dedent

import pytest
from ruamel.yaml import YAML
from seba_sqlite.snapshot import SebaSnapshot
from tests.everest.utils import (
capture_streams,
relpath,
skipif_no_everest_models,
tmpdir,
)

from everest import __version__ as everest_version
from everest.bin.main import start_everest
from everest.config import EverestConfig
Expand All @@ -11,14 +20,6 @@
everserver_status,
wait_for_context,
)
from ruamel.yaml import YAML
from seba_sqlite.snapshot import SebaSnapshot
from tests.everest.utils import (
capture_streams,
relpath,
skipif_no_everest_models,
tmpdir,
)

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
CONFIG_FILE_MINIMAL = "config_minimal.yml"
Expand Down
11 changes: 6 additions & 5 deletions tests/everest/functional/test_ui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import pytest
from PyQt5.QtWidgets import QAction, QPushButton, QWidget
from qtpy.QtCore import Qt
from seba_sqlite.snapshot import SebaSnapshot
from tests.everest.dialogs_mocker import mock_dialogs_all
from tests.everest.utils import relpath, tmpdir

from everest.config import EverestConfig
from everest.detached import (
ServerStatus,
Expand All @@ -7,11 +13,6 @@
wait_for_context,
)
from ieverest import IEverest
from PyQt5.QtWidgets import QAction, QPushButton, QWidget
from qtpy.QtCore import Qt
from seba_sqlite.snapshot import SebaSnapshot
from tests.everest.dialogs_mocker import mock_dialogs_all
from tests.everest.utils import relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
CONFIG_FILE_MINIMAL = "config_minimal.yml"
Expand Down
6 changes: 3 additions & 3 deletions tests/everest/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import pandas as pd
import pytest
from everest.api import EverestDataAPI
from everest.config import EverestConfig
from everest.detached import ServerStatus
from pandas import Timestamp
from seba_sqlite.database import ControlDefinition, Function
from seba_sqlite.snapshot import Metadata, OptimizationInfo, SimulationInfo, Snapshot

from everest.api import EverestDataAPI
from everest.config import EverestConfig
from everest.detached import ServerStatus
from tests.everest.utils import relpath, tmpdir

# Global values used to create the mock snapshot.
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from everest.config import EverestConfig
from everest.simulator import Simulator
from everest.suite import _EverestWorkflow

from tests.everest.utils import relpath, tmp

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_config_branch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest

from everest.bin.config_branch_script import (
_updated_initial_guess,
opt_controls_by_batch,
)
from everest.config_file_loader import load_yaml
from everest.config_keys import ConfigKeys as CK

from tests.everest.utils import relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
6 changes: 3 additions & 3 deletions tests/everest/test_config_file_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from unittest.mock import patch

import pytest
from everest import ConfigKeys as CK
from everest import config_file_loader as loader
from everest.config import EverestConfig
from pydantic_core import ValidationError
from ruamel.yaml import YAML

from everest import ConfigKeys as CK
from everest import config_file_loader as loader
from everest.config import EverestConfig
from tests.everest.utils import relpath, tmpdir

mocked_root = relpath(os.path.join("test_data", "mocked_test_case"))
Expand Down
4 changes: 2 additions & 2 deletions tests/everest/test_config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from typing import Any, Dict, List, Union

import pytest
from pydantic import ValidationError

from everest.config import EverestConfig, ModelConfig
from everest.config.control_variable_config import ControlVariableConfig
from everest.config.sampler_config import SamplerConfig
from pydantic import ValidationError

from tests.everest.utils import tmpdir


Expand Down
4 changes: 2 additions & 2 deletions tests/everest/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import List

import pytest
from pydantic import ValidationError

from everest import ConfigKeys
from everest.config import EverestConfig
from everest.config.control_config import ControlConfig
Expand All @@ -14,8 +16,6 @@
)
from everest.config.input_constraint_config import InputConstraintConfig
from everest.config.well_config import WellConfig
from pydantic import ValidationError

from tests.everest.utils import relpath, tmp, tmpdir

cfg_dir = relpath("test_data", "mocked_test_case")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_cvar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from everest.config import EverestConfig
from everest.suite import _EverestWorkflow

from tests.everest.utils import relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_detached.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest
import requests

from ert.config import ErtConfig, QueueSystem
from ert.storage import open_storage
from everest.config import EverestConfig
Expand Down Expand Up @@ -35,7 +36,6 @@
SIMULATION_DIR,
)
from everest.util import makedirs_if_needed

from tests.everest.utils import capture_logger, relpath, tmpdir


Expand Down
1 change: 0 additions & 1 deletion tests/everest/test_discrete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from everest.config import EverestConfig
from everest.suite import _EverestWorkflow

from tests.everest.utils import relpath, tmpdir

CONFIG_PATH = relpath("..", "..", "examples", "math_func")
Expand Down
4 changes: 2 additions & 2 deletions tests/everest/test_egg_simulation.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import json
import os

import everest
import pytest

import everest
from ert.config import ErtConfig, QueueSystem
from everest.config import EverestConfig
from everest.config.export_config import ExportConfig
from everest.config_keys import ConfigKeys
from everest.export import MetaDataColumnNames
from everest.plugins.site_config_env import PluginSiteConfigEnv
from everest.simulator.everest_to_ert import everest_to_ert_config

from tests.everest.utils import (
everest_default_jobs,
hide_opm,
Expand Down
4 changes: 2 additions & 2 deletions tests/everest/test_environment.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

import everest
import pytest

import everest
from everest.config import EverestConfig
from everest.simulator.everest_to_ert import everest_to_ert_config

from tests.everest.utils import relpath, tmpdir

root = os.path.join("..", "..", "examples", "math_func")
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_everest_initialization.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os

import pytest

from everest.config import EverestConfig
from everest.suite import _EverestWorkflow

from tests.everest.utils import relpath, tmp

NO_PROJECT_RES = (
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_everest_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import patch

import pytest

from ert.config import ErtConfig
from ert.storage import open_storage
from everest.config import EverestConfig
Expand All @@ -15,7 +16,6 @@
)
from everest.suite import _EverestWorkflow
from everest.util import makedirs_if_needed

from tests.everest.utils import relpath, tmpdir


Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_everjobs_io.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import os

import everest
import pytest
from ruamel.yaml import YAML

import everest
from tests.everest.utils import tmpdir


Expand Down
4 changes: 2 additions & 2 deletions tests/everest/test_everlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import tempfile
from pathlib import Path

import everest
import pytest

import everest
from everest import ConfigKeys
from everest.config import EverestConfig
from everest.config_file_loader import yaml_file_to_substituted_config_dict
from everest.util.forward_models import collect_forward_models

from tests.everest.test_config_validation import has_error
from tests.everest.utils import relpath

Expand Down
6 changes: 3 additions & 3 deletions tests/everest/test_everserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from functools import partial
from unittest.mock import patch

from ropt.enums import OptimizerExitCode
from seba_sqlite.snapshot import SebaSnapshot

from everest.config import EverestConfig
from everest.detached import ServerStatus, everserver_status
from everest.detached.jobs import everserver
from everest.simulator import JOB_FAILURE, JOB_SUCCESS
from everest.strings import OPT_FAILURE_REALIZATIONS, SIM_PROGRESS_ENDPOINT
from ropt.enums import OptimizerExitCode
from seba_sqlite.snapshot import SebaSnapshot

from tests.everest.utils import relpath, tmpdir


Expand Down
Loading

0 comments on commit 193ddf2

Please sign in to comment.