Exemplo n.º 1
0
class TestCreatingInvalidNames(unittest.TestCase):
    def setUp(self):
        self.ds = create_test_dataset_1()
        self.ncfs = NCFS(self.ds, None, None, None)

    def tearDown(self):
        self.ds.close()

    def test_dot_file_as_global_attr(self):
        self.ncfs.create('/.foo', mode=int('0100644', 8))
        self.assertFalse('.foo' in self.ds.ncattrs())

    def test_emacs_tempfile_as_global_attr(self):
        self.ncfs.create('/foo~', mode=int('0100644', 8))
        self.assertFalse('foo~' in self.ds.ncattrs())

    def test_dot_file_as_variable_attr(self):
        self.ncfs.create('/foovar/.foo', mode=int('0100644', 8))
        self.assertFalse(self.ncfs.exists('/foovar/.foo'))

    def test_emacs_tempfile_as_variable_attr(self):
        self.ncfs.create('/foovar/foo~', mode=int('0100644', 8))
        self.assertFalse(self.ncfs.exists('/foovar/foo~'))
Exemplo n.º 2
0
class TestGlobalAttrs(unittest.TestCase):
    def setUp(self):
        self.ds = create_test_dataset_1()
        self.ncfs = NCFS(self.ds, None, None, None)

    def tearDown(self):
        self.ds.close()

    def test_creating_new_global_attr(self):
        self.ncfs.create('/attr2', mode=int('0100644', 8))
        self.assertTrue('attr2' in self.ds.ncattrs())

    def test_writing_to_existing_global_attr(self):
        self.ncfs.write('/attr1', 'newattr1val', offset=0)
        self.assertEqual(self.ds.getncattr('attr1'), 'newattr1val')

    def test_writing_to_existing_global_attr_2(self):
        self.ncfs.write('/attr1', 'x', offset=0)
        self.assertEqual(self.ds.getncattr('attr1'), 'xttrval1')

    def test_is_global_attr_on_existing_attr(self):
        self.assertTrue(self.ncfs.is_global_attr('/attr1'))

    def test_is_global_attr_on_nonexisting_attr(self):
        self.assertTrue(self.ncfs.is_global_attr('/attr99'))

    def test_get_global_attr(self):
        self.assertTrue(self.ncfs.get_global_attr('/attr1') is not None)

    def test_exist_on_global_attr(self):
        self.assertTrue(self.ncfs.exists('/attr1'))

    def test_is_var_dir_on_existing_global_attr(self):
        self.assertFalse(self.ncfs.is_var_dir('/attr1'))

    def test_deleting_existing_global_attr(self):
        self.ncfs.unlink('/attr1')
        self.assertFalse('attr1' in self.ds.ncattrs())
Exemplo n.º 3
0
class TestExists(unittest.TestCase):
    def setUp(self):
        self.ncfs = NCFS(FakeDataset(), None, None, None)

    def test_exists_1(self):
        self.assertTrue(self.ncfs.exists('/foovar'))

    def test_exists_2(self):
        self.assertTrue(self.ncfs.exists('/foovar/fooattr'))

    def test_exists_3(self):
        self.assertFalse(self.ncfs.exists('/foovar/fooattr/foo'))

    def test_exists_4(self):
        self.assertTrue(self.ncfs.exists('/'))

    def test_exists_5(self):
        self.assertTrue(self.ncfs.exists('/foovar/DATA_REPR'))

    def test_exists_6(self):
        self.assertTrue(self.ncfs.exists('/foovar/DIMENSIONS'))