コード例 #1
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
    def test_shotgun_fields(self):
        """
        Test keys made with shotgun entity type and field name.
        """
        data = {"string" : {"type": "str",
                            "shotgun_entity_type": "entity one",
                            "shotgun_field_name": "field one"},
               "integer" : {"type": "int",
                            "shotgun_entity_type": "entity two",
                            "shotgun_field_name": "field two"},
               "sequence" : {"type": "sequence",
                            "shotgun_entity_type": "entity three",
                            "shotgun_field_name": "field three"}}

        result = make_keys(data)

        str_key = result.get("string")
        self.assertIsInstance(str_key, StringKey)
        self.assertEquals("entity one", str_key.shotgun_entity_type)
        self.assertEquals("field one", str_key.shotgun_field_name)

        int_key = result.get("integer")
        self.assertIsInstance(int_key, IntegerKey)
        self.assertEquals("entity two", int_key.shotgun_entity_type)
        self.assertEquals("field two", int_key.shotgun_field_name)

        seq_key = result.get("sequence")
        self.assertIsInstance(seq_key, SequenceKey)
        self.assertEquals("entity three", seq_key.shotgun_entity_type)
        self.assertEquals("field three", seq_key.shotgun_field_name)
コード例 #2
0
    def test_int(self):
        data = {
            "simple": {
                "type": "int"
            },
            "complex": {
                "type": "int",
                "default": 2,
                "choices": [1, 2],
                "format_spec": "03"
            }
        }
        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, IntegerKey)

        simple_key = result.get("simple")
        complex_key = result.get("complex")

        self.assertEquals("simple", simple_key.name)
        self.assertEquals(None, simple_key.default)
        self.assertEquals([], simple_key.choices)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals(2, complex_key.default)
        self.assertEquals([1, 2], complex_key.choices)
        self.assertEquals("03", complex_key.format_spec)
コード例 #3
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
    def test_string(self):
        data = {"simple": {"type": "str"},
                "alpha" : {"type": "str", "filter_by": "alphanumeric"},
                "complex": {"type": "str", "default": "a", "choices": ["a", "b"]}}
        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, StringKey)

        simple_key = result.get("simple")
        alpha_key = result.get("alpha")
        complex_key = result.get("complex")

        self.assertEquals("simple", simple_key.name)
        self.assertEquals(None, simple_key.default)
        self.assertEquals([], simple_key.choices)

        self.assertEquals("alpha", alpha_key.name)
        self.assertEquals(None, alpha_key.default)
        self.assertEquals([], alpha_key.choices)
        self.assertEquals("alphanumeric", alpha_key.filter_by)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals("a", complex_key.default)
        self.assertEquals(["a", "b"], complex_key.choices)
コード例 #4
0
    def test_shotgun_fields(self):
        """
        Test keys made with shotgun entity type and field name.
        """
        data = {"string" : {"type": "str",
                            "shotgun_entity_type": "entity one",
                            "shotgun_field_name": "field one"},
               "integer" : {"type": "int",
                            "shotgun_entity_type": "entity two",
                            "shotgun_field_name": "field two"},
               "sequence" : {"type": "sequence",
                            "shotgun_entity_type": "entity three",
                            "shotgun_field_name": "field three"}}

        result = make_keys(data)

        str_key = result.get("string")
        self.assertIsInstance(str_key, StringKey)
        self.assertEquals("entity one", str_key.shotgun_entity_type)
        self.assertEquals("field one", str_key.shotgun_field_name)

        int_key = result.get("integer")
        self.assertIsInstance(int_key, IntegerKey)
        self.assertEquals("entity two", int_key.shotgun_entity_type)
        self.assertEquals("field two", int_key.shotgun_field_name)

        seq_key = result.get("sequence")
        self.assertIsInstance(seq_key, SequenceKey)
        self.assertEquals("entity three", seq_key.shotgun_entity_type)
        self.assertEquals("field three", seq_key.shotgun_field_name)
コード例 #5
0
    def test_string(self):
        data = {"simple": {"type": "str"},
                "alpha" : {"type": "str", "filter_by": "alphanumeric"},
                "complex": {"type": "str", "default": "a", "choices": ["a", "b"]}}
        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, StringKey)

        simple_key = result.get("simple")
        alpha_key = result.get("alpha")
        complex_key = result.get("complex")

        self.assertEquals("simple", simple_key.name)
        self.assertEquals(None, simple_key.default)
        self.assertEquals([], simple_key.choices)

        self.assertEquals("alpha", alpha_key.name)
        self.assertEquals(None, alpha_key.default)
        self.assertEquals([], alpha_key.choices)
        self.assertEquals("alphanumeric", alpha_key.filter_by)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals("a", complex_key.default)
        self.assertEquals(["a", "b"], complex_key.choices)
コード例 #6
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
    def test_sequence(self):
        data = {"simple": {"type": "sequence"},
                "complex": {"type": "sequence", "format_spec": "03"}}

        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, SequenceKey)

        simple_key = result.get("simple")
        complex_key = result.get("complex")

        self.assertEquals("simple", simple_key.name)
        self.assertEquals("01", simple_key.format_spec)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals("03", complex_key.format_spec)
コード例 #7
0
    def test_sequence(self):
        data = {"simple": {"type": "sequence"},
                "complex": {"type": "sequence", "format_spec": "03"}}

        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, SequenceKey)

        simple_key = result.get("simple")
        complex_key = result.get("complex")

        self.assertEquals("simple", simple_key.name)
        self.assertEquals("01", simple_key.format_spec)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals("03", complex_key.format_spec)
コード例 #8
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
    def test_int(self):
        data = {"simple": {"type": "int"},
                "complex": {"type": "int", "default": 2, "choices": [1,2], "format_spec": "03"}}
        result = make_keys(data)
        # check type
        for key in result.values():
            self.assertIsInstance(key, IntegerKey)

        simple_key = result.get("simple")
        complex_key = result.get("complex")
        
        self.assertEquals("simple", simple_key.name)
        self.assertEquals(None, simple_key.default)
        self.assertEquals([], simple_key.choices)

        self.assertEquals("complex", complex_key.name)
        self.assertEquals(2, complex_key.default)
        self.assertEquals([1, 2], complex_key.choices)
        self.assertEquals("03", complex_key.format_spec)
コード例 #9
0
 def test_aliases(self):
     data = {"real_key_name": {"type": "str", "alias": "alias_name"}}
     keys = make_keys(data)
     key = keys.get("real_key_name")
     self.assertIsInstance(key, StringKey)
     self.assertEquals("alias_name", key.name)
コード例 #10
0
 def test_no_data(self):
     data = {}
     result = make_keys(data)
     self.assertEquals({}, result)
コード例 #11
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
 def test_aliases(self):
     data = {"real_key_name": {"type":"str", "alias":"alias_name"}}
     keys = make_keys(data)
     key = keys.get("real_key_name")
     self.assertIsInstance(key, StringKey)
     self.assertEquals("alias_name", key.name)
コード例 #12
0
ファイル: test_templatekey.py プロジェクト: bdeluca/tk-core
 def test_no_data(self):
     data = {}
     result = make_keys(data)
     self.assertEquals({}, result)