コード例 #1
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def setUp(self):
     # None token CFVariableMixin
     self.cf_var = CFVariableMixin()
     self.cf_var.standard_name = None
     self.cf_var.long_name = None
     self.cf_var.var_name = None
     self.cf_var.attributes = {}
     self.default = CFVariableMixin._DEFAULT_NAME
     # bad token CFVariableMixin
     self.cf_bad = CFVariableMixin()
     self.cf_bad.standard_name = None
     self.cf_bad.long_name = 'nope nope'
     self.cf_bad.var_name = None
     self.cf_bad.attributes = {'STASH': 'nope nope'}
コード例 #2
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_pass_mixture(self):
     token = 'S.imple@one+two_3'
     result = CFVariableMixin.token(token)
     self.assertEqual(result, token)
コード例 #3
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
class Test_name(tests.IrisTest):
    def setUp(self):
        # None token CFVariableMixin
        self.cf_var = CFVariableMixin()
        self.cf_var.standard_name = None
        self.cf_var.long_name = None
        self.cf_var.var_name = None
        self.cf_var.attributes = {}
        self.default = CFVariableMixin._DEFAULT_NAME
        # bad token CFVariableMixin
        self.cf_bad = CFVariableMixin()
        self.cf_bad.standard_name = None
        self.cf_bad.long_name = 'nope nope'
        self.cf_bad.var_name = None
        self.cf_bad.attributes = {'STASH': 'nope nope'}

    def test_standard_name(self):
        token = 'air_temperature'
        self.cf_var.standard_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_long_name(self):
        token = 'long_name'
        self.cf_var.long_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_var_name(self):
        token = 'var_name'
        self.cf_var.var_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_stash(self):
        token = 'stash'
        self.cf_var.attributes['STASH'] = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_default(self):
        result = self.cf_var.name()
        self.assertEqual(result, self.default)

    def test_token_long_name(self):
        token = 'long_name'
        self.cf_bad.long_name = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_var_name(self):
        token = 'var_name'
        self.cf_bad.var_name = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_stash(self):
        token = 'stash'
        self.cf_bad.attributes['STASH'] = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_default(self):
        result = self.cf_var.name(token=True)
        self.assertEqual(result, self.default)

    def test_fail_token_default(self):
        emsg = 'Cannot retrieve a valid name token'
        with self.assertRaisesRegexp(ValueError, emsg):
            self.cf_var.name(default='_nope', token=True)
コード例 #4
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_pass_simple(self):
     token = 'simple'
     result = CFVariableMixin.token(token)
     self.assertEqual(result, token)
コード例 #5
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_pass_leading_digit(self):
     token = '123simple'
     result = CFVariableMixin.token(token)
     self.assertEqual(result, token)
コード例 #6
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_fail_space(self):
     result = CFVariableMixin.token('nope nope')
     self.assertIsNone(result)
コード例 #7
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_fail_colon(self):
     result = CFVariableMixin.token('nope:')
     self.assertIsNone(result)
コード例 #8
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_fail_leading_underscore(self):
     result = CFVariableMixin.token('_nope')
     self.assertIsNone(result)
コード例 #9
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_fail_leading_at(self):
     result = CFVariableMixin.token('@nope')
     self.assertIsNone(result)
コード例 #10
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_none_standard_name(self):
     cf_var = CFVariableMixin()
     cf_var.standard_name = None
     self.assertIsNone(cf_var.standard_name)
コード例 #11
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_passthru_None(self):
     result = CFVariableMixin.token(None)
     self.assertIsNone(result)
コード例 #12
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_invalid_standard_name(self):
     cf_var = CFVariableMixin()
     emsg = "'not_a_standard_name' is not a valid standard_name"
     with self.assertRaisesRegexp(ValueError, emsg):
         cf_var.standard_name = 'not_a_standard_name'
コード例 #13
0
ファイル: test_CFVariableMixin.py プロジェクト: zklaus/iris
 def test_valid_standard_name(self):
     cf_var = CFVariableMixin()
     cf_var.standard_name = 'air_temperature'
     self.assertEqual(cf_var.standard_name, 'air_temperature')
コード例 #14
0
ファイル: test_CFVariableMixin.py プロジェクト: zmaalick/iris
class Test_name(tests.IrisTest):
    def setUp(self):
        # None token CFVariableMixin
        self.cf_var = CFVariableMixin()
        self.cf_var.standard_name = None
        self.cf_var.long_name = None
        self.cf_var.var_name = None
        self.cf_var.attributes = {}
        self.default = CFVariableMixin._DEFAULT_NAME
        # bad token CFVariableMixin
        self.cf_bad = CFVariableMixin()
        self.cf_bad.standard_name = None
        self.cf_bad.long_name = "nope nope"
        self.cf_bad.var_name = None
        self.cf_bad.attributes = {"STASH": "nope nope"}

    def test_standard_name(self):
        token = "air_temperature"
        self.cf_var.standard_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_long_name(self):
        token = "long_name"
        self.cf_var.long_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_var_name(self):
        token = "var_name"
        self.cf_var.var_name = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_stash(self):
        token = "stash"
        self.cf_var.attributes["STASH"] = token
        result = self.cf_var.name()
        self.assertEqual(result, token)

    def test_default(self):
        result = self.cf_var.name()
        self.assertEqual(result, self.default)

    def test_token_long_name(self):
        token = "long_name"
        self.cf_bad.long_name = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_var_name(self):
        token = "var_name"
        self.cf_bad.var_name = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_stash(self):
        token = "stash"
        self.cf_bad.attributes["STASH"] = token
        result = self.cf_bad.name(token=True)
        self.assertEqual(result, token)

    def test_token_default(self):
        result = self.cf_var.name(token=True)
        self.assertEqual(result, self.default)

    def test_fail_token_default(self):
        emsg = "Cannot retrieve a valid name token"
        with self.assertRaisesRegex(ValueError, emsg):
            self.cf_var.name(default="_nope", token=True)
コード例 #15
0
ファイル: test_CFVariableMixin.py プロジェクト: zmaalick/iris
 def test_fail_leading_plus(self):
     result = CFVariableMixin.token("+nope")
     self.assertIsNone(result)
コード例 #16
0
ファイル: test_CFVariableMixin.py プロジェクト: zmaalick/iris
 def setUp(self):
     self.cf_var = CFVariableMixin()
     self.cf_var.standard_name = None
     self.cf_var.long_name = None
     self.cf_var.var_name = None
     self.cf_var.attributes = dict()