コード例 #1
0
 def test_basics(self):
     """Attribute creation and attribute references"""
     attr = Attribute("foo")
     self.assertEqual("foo", attr.name)
     self.assertEqual("foo", str(attr))
     self.assertEqual("foo", attr.ref())
     self.assertEqual("foo", attr.ref(simplify=False))
     self.assertEqual("foo", attr.ref(simplify=True))
コード例 #2
0
ファイル: test_model.py プロジェクト: 6si/cubes
 def test_basics(self):
     """Attribute creation and attribute references"""
     attr = Attribute("foo")
     self.assertEqual("foo", attr.name)
     self.assertEqual("foo", str(attr))
     self.assertEqual("foo", attr.ref())
     self.assertEqual("foo", attr.ref(simplify=False))
     self.assertEqual("foo", attr.ref(simplify=True))
コード例 #3
0
ファイル: test_model.py プロジェクト: 6si/cubes
    def test_locale(self):
        """References to localizable attributes"""

        attr = Attribute("foo")
        self.assertRaises(ArgumentError, attr.ref, locale="xx")

        attr = Attribute("foo", locales=["en", "sk"])
        self.assertEqual("foo", attr.name)
        self.assertEqual("foo", str(attr))
        self.assertEqual("foo", attr.ref())
        self.assertEqual("foo.en", attr.ref(locale="en"))
        self.assertEqual("foo.sk", attr.ref(locale="sk"))
        self.assertRaises(ArgumentError, attr.ref, locale="xx")
コード例 #4
0
    def setUp(self):
        attrs = [
            {
                "name": "a"
            },
            {
                "name": "b",
                "expression": "a + 1"
            },
            {
                "name": "c",
                "expression": "b + 1"
            },
            {
                "name": "d",
                "expression": "10"
            },
            {
                "name": "e",
                "expression": "unknown"
            },
            {
                "name": "loop1",
                "expression": "loop2 + 1"
            },
            {
                "name": "loop2",
                "expression": "loop1 + 1"
            },
            {
                "name": "indirect_loop1",
                "expression": "intermediate"
            },
            {
                "name": "intermediate",
                "expression": "indirect_loop1"
            },
            {
                "name": "indirect_loop2",
                "expression": "indirect_loop1"
            },
        ]

        self.attrs = {
            attr["name"]: Attribute.from_metadata(attr)
            for attr in attrs
        }
        self.deps = {
            name: attr.dependencies
            for name, attr in self.attrs.items()
        }
コード例 #5
0
ファイル: test_expressions.py プロジェクト: Greyvend/cubes
    def setUp(self):
        attrs = [
            {"name": "a"},
            {"name": "b", "expression": "a + 1"},
            {"name": "c", "expression": "b + 1"},
            {"name": "d", "expression": "10"},
            {"name": "e", "expression": "unknown"},
            {"name": "loop1", "expression": "loop2 + 1"},
            {"name": "loop2", "expression": "loop1 + 1"},
            {"name": "indirect_loop1", "expression": "intermediate"},
            {"name": "intermediate", "expression": "indirect_loop1"},
            {"name": "indirect_loop2", "expression": "indirect_loop1"},
        ]

        self.attrs = {attr["name"]: Attribute.from_metadata(attr) for attr in attrs}
        self.deps = {name: attr.dependencies for name, attr in self.attrs.items()}
コード例 #6
0
    def test_locale(self):
        """References to localizable attributes"""

        attr = Attribute("foo")
        self.assertRaises(ArgumentError, attr.ref, locale="xx")

        attr = Attribute("foo", locales=["en", "sk"])
        self.assertEqual("foo", attr.name)
        self.assertEqual("foo", str(attr))
        self.assertEqual("foo", attr.ref())
        self.assertEqual("foo.en", attr.ref(locale="en"))
        self.assertEqual("foo.sk", attr.ref(locale="sk"))
        self.assertRaises(ArgumentError, attr.ref, locale="xx")