當前位置: 首頁>>代碼示例>>Python>>正文


Python Resource.is_materialized方法代碼示例

本文整理匯總了Python中stormpath.resources.base.Resource.is_materialized方法的典型用法代碼示例。如果您正苦於以下問題:Python Resource.is_materialized方法的具體用法?Python Resource.is_materialized怎麽用?Python Resource.is_materialized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stormpath.resources.base.Resource的用法示例。


在下文中一共展示了Resource.is_materialized方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_resource_init_by_href

# 需要導入模塊: from stormpath.resources.base import Resource [as 別名]
# 或者: from stormpath.resources.base.Resource import is_materialized [as 別名]
    def test_resource_init_by_href(self):
        r = Resource(MagicMock(), href='test/resource')

        # it's not materialized yet
        self.assertFalse(r.is_materialized())
        # it's not new (has href)
        self.assertFalse(r.is_new())
        # it know what it is
        self.assertEqual(r.href, 'test/resource')
        # href is not writable
        with self.assertRaises(AttributeError):
            r.href = 'abc'
        # non-existing attribute access is handled correctly
        with self.assertRaises(AttributeError):
            r.foo
開發者ID:senko,項目名稱:stormpath-sdk-python,代碼行數:17,代碼來源:test_resource.py

示例2: test_resource_init_by_properties

# 需要導入模塊: from stormpath.resources.base import Resource [as 別名]
# 或者: from stormpath.resources.base.Resource import is_materialized [as 別名]
    def test_resource_init_by_properties(self):
        r = Resource(MagicMock(), properties={
            'href': 'test/resource',
            'name': 'Test Resource',
            'someProperty': 'value'
        })

        # we have the resource data
        self.assertTrue(r.is_materialized())
        # it's not new (has href)
        self.assertFalse(r.is_new())
        # it knows what it is
        self.assertEqual(r.href, 'test/resource')
        # we can access the attributes
        self.assertEqual(r.name, 'Test Resource')
        # attribute name was correctly converted
        self.assertEqual(r.some_property, 'value')
        # there are no writable attributes
        with self.assertRaises(AttributeError):
            r.name = 5
開發者ID:senko,項目名稱:stormpath-sdk-python,代碼行數:22,代碼來源:test_resource.py


注:本文中的stormpath.resources.base.Resource.is_materialized方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。