Exemplo n.º 1
0
    def test_eq_fail(self):
        properties = [prop for prop in self.pcomp.values()]
        pcomp = metocean.PropertyComponent('uri', properties)
        self.assertNotEqual(self.pcomp, pcomp)

        pcomp = metocean.PropertyComponent(self.pcomp.uri, properties[:-1])
        self.assertNotEqual(self.pcomp, pcomp)

        properties = [stock.property_cf_standard_name(),
                      stock.property_cf_units(),
                      stock.property_cf_type(),
                      stock.property_um_stash()]
        pcomp = metocean.PropertyComponent(self.pcomp.uri, properties)

        properties = [stock.property_cf_standard_name(),
                      stock.property_cf_units(),
                      stock.property_um_stash()]
        pcomp = metocean.PropertyComponent(self.pcomp.uri, properties)
        self.assertNotEqual(self.pcomp, pcomp)

        uri, name, value, operator = stock.property_cf_standard_name()
        properties = [metocean.Property(uri, name.data, value, operator),
                      stock.property_cf_units(),
                      stock.property_cf_type()]
        pcomp = metocean.PropertyComponent(self.pcomp.uri, properties)
        self.assertNotEqual(self.pcomp, pcomp)
Exemplo n.º 2
0
 def test_getattr(self):
     prop = stock.property_cf_standard_name()
     self.assertEqual(self.pcomp.standard_name, prop)
     prop = stock.property_cf_units()
     self.assertEqual(self.pcomp.units, prop)
     prop = stock.property_cf_type()
     self.assertEqual(self.pcomp.type, prop)
     self.assertIsNone(self.pcomp.wibble)
Exemplo n.º 3
0
    def test_contains(self):
        prop = stock.property_cf_standard_name()
        self.assertTrue(prop in self.pcomp)
        self.assertTrue(prop.name in self.pcomp)
        self.assertTrue(prop.name.data in self.pcomp)
        self.assertTrue(prop.name.notation in self.pcomp)

        prop = stock.property_um_stash()
        self.assertFalse(prop in self.pcomp)
        self.assertFalse(prop.name in self.pcomp)
        self.assertFalse(prop.name.data in self.pcomp)
        self.assertFalse(prop.name.notation in self.pcomp)
Exemplo n.º 4
0
    def test_getitem(self):
        prop = stock.property_cf_standard_name()
        self.assertEqual(self.comp[prop.name], prop)
        self.assertEqual(self.comp[prop.name.notation], prop)
        self.assertEqual(self.comp[0], stock.property_component_cf())
        self.assertIsNone(self.comp['wibble'])

        self.assertEqual(self.ccomp[0], stock.simple_component_cf())

        with self.assertRaises(TypeError):
            self.ccomp[prop.name]
        with self.assertRaises(TypeError):
            self.ccomp[prop.name.notation]
        with self.assertRaises(TypeError):
            self.ccomp['wibble']
Exemplo n.º 5
0
    def test_getattr(self):
        prop = stock.property_cf_standard_name()
        self.assertEqual(self.comp.standard_name, prop)
        prop = stock.property_cf_units()
        self.assertEqual(self.comp.units, prop)
        prop = stock.property_cf_type()
        self.assertEqual(self.comp.type, prop)
        self.assertIsNone(self.comp.wibble)

        with self.assertRaises(TypeError):
            self.ccomp.standard_name
        with self.assertRaises(TypeError):
            self.ccomp.units
        with self.assertRaises(TypeError):
            self.ccomp.type
        with self.assertRaises(TypeError):
            self.ccomp.wibble
Exemplo n.º 6
0
    def test_contains(self):
        prop = stock.property_cf_standard_name()
        self.assertTrue(prop in self.comp)
        self.assertTrue(prop.name in self.comp)
        self.assertTrue(prop.name.data in self.comp)
        self.assertTrue(prop.name.notation in self.comp)

        with self.assertRaises(TypeError):
            prop in self.ccomp
        with self.assertRaises(TypeError):
            prop.name in self.ccomp
        with self.assertRaises(TypeError):
            prop.name.data in self.ccomp
        with self.assertRaises(TypeError):
            prop.name.notation in self.ccomp

        prop = stock.property_um_stash()
        self.assertFalse(prop in self.comp)
        self.assertFalse(prop.name in self.comp)
        self.assertFalse(prop.name.data in self.comp)
        self.assertFalse(prop.name.notation in self.comp)
Exemplo n.º 7
0
 def setUp(self):
     self.prop = stock.property_cf_standard_name()
     self.uri, self.name, self.value, self.operator = self.prop
     self.cprop = metocean.Property('uri', 'name',
                                    stock.property_component_cf(),
                                    'operator')
Exemplo n.º 8
0
 def test_getitem(self):
     prop = stock.property_cf_standard_name()
     self.assertEqual(self.pcomp[prop.name], prop)
     self.assertEqual(self.pcomp[prop.name.notation], prop)
     self.assertIsNone(self.pcomp['wibble'])