/usr/lib/python3/dist-packages/pydap/tests/test_parsers_das.py is in python3-pydap 3.2.2+ds1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | """Test DAS parsing functions."""
import numpy as np
from pydap.parsers.das import add_attributes, parse_das
from pydap.parsers.dds import build_dataset
from pydap.tests.test_parsers_dds import DDS
import unittest
DAS = """Attributes {
structure {
b {
Int value 1;
Float32 missing nan;
String foo "one", "two";
}
}
structure.i {
Int answer 42;
}
meta {
String debug 1;
}
SPEH {
Int debug 1;
Int TIME 0;
Float32 COADSX 1e20;
String COADSY "zero";
}
}"""
# It is important to add attributes that have the same
# name as the dimensions of SPEH. This is an edge
# case that can break the das parser.
class TestParseDAS(unittest.TestCase):
"""Test DAS parser."""
def setUp(self):
"""Load a dataset and apply DAS to it."""
self.dataset = build_dataset(DDS)
attributes = parse_das(DAS)
add_attributes(self.dataset, attributes)
def test_basic(self):
"""Test a basic attribute."""
self.assertEqual(self.dataset.structure.b.value, 1)
def test_nan(self):
"""Test NaN."""
self.assertTrue(np.isnan(self.dataset.structure.b.missing))
def test_multiple_values(self):
"""Test attributes with multiple values."""
self.assertEqual(self.dataset.structure.b.foo, ["one", "two"])
def test_dot_attribute(self):
"""Test dotted attributes."""
self.assertEqual(self.dataset.structure.i.answer, 42)
def test_meta_attributes(self):
"""Test attributes not associated with any variables."""
self.assertEqual(self.dataset.meta, {"debug": "1"})
def test_SPEH_attributes(self):
"""Test attributes not associated with any variables."""
self.assertEqual(self.dataset.SPEH.debug, 1)
self.assertEqual(self.dataset.SPEH.attributes['TIME'], 0)
self.assertEqual(self.dataset.SPEH.attributes['COADSX'], 1e20)
self.assertEqual(self.dataset.SPEH.attributes['COADSY'], "zero")
|