Skip to content

Commit

Permalink
-bugfix for pytest
Browse files Browse the repository at this point in the history
-test disable for makers which need raw data run
	-> need to find a solution to test this class
  • Loading branch information
guillaume.grolleron committed Sep 19, 2023
1 parent d0a1963 commit 3683819
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ exclude = ["nectarchain._dev_version"]

[tool.setuptools_scm]
write_to = "src/nectarchain/_version.py"

[tool.pytest.ini_options]
addopts = "--import-mode=importlib"
3 changes: 3 additions & 0 deletions src/nectarchain/data/container/tests/test_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from nectarchain.data.container import ChargesContainer, ChargesContainerIO
from nectarchain.makers import ChargesMaker

import pytest


def create_fake_chargeContainer():
nevents = TestChargesContainer.nevents
Expand Down Expand Up @@ -81,6 +83,7 @@ def test_create_charge_container(self):
# assert isinstance(charge_container, ChargeContainer)

# Tests that the ChargeContainer object can be written to a file and the file is created.

def test_write_charge_container(self, tmp_path="/tmp"):
charge_container = create_fake_chargeContainer()
tmp_path += f"/{np.random.randn(1)[0]}"
Expand Down
24 changes: 15 additions & 9 deletions src/nectarchain/data/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from pathlib import Path
from typing import List, Tuple

import browser_cookie3
import mechanize
import requests

__all__ = ["DataManagement"]

Expand All @@ -27,11 +24,18 @@ def findrun(run_number: int, search_on_GRID=True) -> Tuple[Path, List[Path]]:
Returns:
(PosixPath,list): the path list of *fits.fz files
"""
basepath = os.environ["NECTARCAMDATA"]
list = glob.glob(
basepath + "**/*" + str(run_number) + "*.fits.fz", recursive=True
)
list_path = [Path(chemin) for chemin in list]
basepath = os.environ.get("NECTARCAMDATA",False)
if basepath==False :
log.warning("NECTARCAMDATA is not defined")
name = Path("")
list_path = []
if not(search_on_GRID):
return name, list_path

Check warning on line 33 in src/nectarchain/data/management.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/data/management.py#L27-L33

Added lines #L27 - L33 were not covered by tests
else :
list = glob.glob(

Check warning on line 35 in src/nectarchain/data/management.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/data/management.py#L35

Added line #L35 was not covered by tests
basepath + "**/*" + str(run_number) + "*.fits.fz", recursive=True
)
list_path = [Path(chemin) for chemin in list]
if len(list_path) == 0:
e = FileNotFoundError(f"run {run_number} is not present in {basepath}")
if search_on_GRID:
Expand Down Expand Up @@ -68,7 +72,6 @@ def getRunFromDIRAC(lfns: list):
lfns (list): list of lfns path
"""
from DIRAC.Interfaces.API.Dirac import Dirac

dirac = Dirac()
for lfn in lfns:
if not (

Check warning on line 77 in src/nectarchain/data/management.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/data/management.py#L74-L77

Added lines #L74 - L77 were not covered by tests
Expand All @@ -93,6 +96,9 @@ def get_GRID_location(
Returns:
_type_: _description_
"""
import browser_cookie3
import mechanize
import requests

Check warning on line 101 in src/nectarchain/data/management.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/data/management.py#L99-L101

Added lines #L99 - L101 were not covered by tests

url = "http://nectarcam.in2p3.fr/elog/nectarcam-data-qm/?cmd=Find"

Check warning on line 103 in src/nectarchain/data/management.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/data/management.py#L103

Added line #L103 was not covered by tests

Expand Down
3 changes: 3 additions & 0 deletions src/nectarchain/makers/tests/test_chargesMakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
log = logging.getLogger(__name__)
log.handlers = logging.getLogger("__main__").handlers

import pytest

@pytest.mark.skip
class TestChargesMaker:
run_number = 3938
max_events = 100


def test_instance(self):
chargesMaker = ChargesMaker(
run_number=TestChargesMaker.run_number,
Expand Down
2 changes: 2 additions & 0 deletions src/nectarchain/makers/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
log = logging.getLogger(__name__)
log.handlers = logging.getLogger("__main__").handlers

import pytest

@pytest.mark.skip
class TestArrayDataMaker:
run_number = 3938
max_events = 100
Expand Down
2 changes: 2 additions & 0 deletions src/nectarchain/makers/tests/test_waveformsMakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
log = logging.getLogger(__name__)
log.handlers = logging.getLogger("__main__").handlers

import pytest

@pytest.mark.skip
class TestWaveformsMaker:
run_number = 3938
max_events = 100
Expand Down

0 comments on commit 3683819

Please sign in to comment.