File: test_lockfile.py

package info (click to toggle)
eumdac 3.0.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 716 kB
  • sloc: python: 7,325; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pytest
import tempfile
import os

from datetime import timedelta
from eumdac.lockfile import open_locked


@pytest.fixture(scope="function")
def lockfile_path(tmp_path):
    lockfile = tmp_path / "lockfile"
    yield lockfile
    if os.path.exists(lockfile):
        os.remove(lockfile)


def test_open_lock(lockfile_path):
    with open_locked(lockfile_path) as lf:
        assert os.path.exists(lockfile_path)


def test_multiple_lock(lockfile_path):
    with open_locked(lockfile_path) as lf:
        with open_locked(lockfile_path, timeout=timedelta(seconds=1)) as lf2:
            assert lf2 is None