File: test_errors.py

package info (click to toggle)
zarr 3.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,068 kB
  • sloc: python: 31,589; makefile: 10
file content (78 lines) | stat: -rw-r--r-- 2,632 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""Test errors"""

from zarr.errors import (
    ArrayNotFoundError,
    ContainsArrayAndGroupError,
    ContainsArrayError,
    ContainsGroupError,
    GroupNotFoundError,
    MetadataValidationError,
    NodeTypeValidationError,
)


def test_group_not_found_error() -> None:
    """
    Test that calling GroupNotFoundError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = GroupNotFoundError("store", "path")
    assert str(err) == "No group found in store 'store' at path 'path'"


def test_array_not_found_error() -> None:
    """
    Test that calling ArrayNotFoundError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = ArrayNotFoundError("store", "path")
    assert str(err) == "No array found in store 'store' at path 'path'"


def test_metadata_validation_error() -> None:
    """
    Test that calling MetadataValidationError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = MetadataValidationError("a", "b", "c")
    assert str(err) == "Invalid value for 'a'. Expected 'b'. Got 'c'."


def test_contains_group_error() -> None:
    """
    Test that calling ContainsGroupError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = ContainsGroupError("store", "path")
    assert str(err) == "A group exists in store 'store' at path 'path'."


def test_contains_array_error() -> None:
    """
    Test that calling ContainsArrayError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = ContainsArrayError("store", "path")
    assert str(err) == "An array exists in store 'store' at path 'path'."


def test_contains_array_and_group_error() -> None:
    """
    Test that calling ContainsArrayAndGroupError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = ContainsArrayAndGroupError("store", "path")
    assert str(err) == (
        "Array and group metadata documents (.zarray and .zgroup) were both found in store 'store' "
        "at path 'path'. Only one of these files may be present in a given directory / prefix. "
        "Remove the .zarray file, or the .zgroup file, or both."
    )


def test_node_type_validation_error() -> None:
    """
    Test that calling NodeTypeValidationError with multiple arguments returns a formatted string.
    This is deprecated behavior.
    """
    err = NodeTypeValidationError("a", "b", "c")
    assert str(err) == "Invalid value for 'a'. Expected 'b'. Got 'c'."