当前位置: 首页>>代码示例>>Python>>正文


Python util.to_xml函数代码示例

本文整理汇总了Python中pyactiveresource.util.to_xml函数的典型用法代码示例。如果您正苦于以下问题:Python to_xml函数的具体用法?Python to_xml怎么用?Python to_xml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了to_xml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_save

    def test_save(self):
        # Return an object with id for a post(save) request.
        self.http.respond_to("POST", "/stores.xml", self.xml_headers, util.to_xml(self.general_store))
        # Return an object for a put request.
        self.http.respond_to("PUT", "/stores/1.xml", self.xml_headers, util.to_xml(self.store_update, root="store"))

        store = self.store(self.store_new)
        store.save()
        self.assertEqual(self.general_store, store.attributes)
        store.manager_id = 3
        store.save()
开发者ID:bieli,项目名称:Taskler,代码行数:11,代码来源:activeresource_test.py

示例2: test_reload

 def test_reload(self):
     self.http.respond_to(
         'GET', '/people/1.xml', {}, util.to_xml(self.arnold, root='person'))
     arnold = self.person.find(1)
     arnold.name = 'someone else'
     arnold.reload()
     self.assertEqual(self.arnold, arnold.attributes)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例3: test_find_should_handle_array_query_args

 def test_find_should_handle_array_query_args(self):
     query = urllib.parse.urlencode({'vars[]': ['a', 'b', 'c']}, True)
     self.http.respond_to(
         'GET', '/people.xml?%s' % query, {},
         util.to_xml([self.arnold], root='people'))
     arnold = self.person.find_first(vars=['a', 'b', 'c'])
     self.assertEqual(self.arnold, arnold.attributes)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例4: test_find_should_handle_dictionary_query_args_with_array_value

 def test_find_should_handle_dictionary_query_args_with_array_value(self):
     query = urllib.parse.urlencode({'vars[key][]': ['val1', 'val2']}, True)
     self.http.respond_to(
         'GET', '/people.xml?%s' % query, {},
         util.to_xml([self.arnold], root='people'))
     arnold = self.person.find_first(vars={'key': ['val1', 'val2']})
     self.assertEqual(self.arnold, arnold.attributes)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例5: test_set_prefix_source

 def test_set_prefix_source(self):
     self.http.respond_to(
         'GET', '/stores/1/people.xml?name=Ralph', {},
         util.to_xml([], root='people'))
     self.person.prefix_source = '/stores/${store_id}/'
     nobody = self.person.find(store_id=1, name='Ralph')
     self.assertEqual([], nobody)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例6: test_save_xml_format

    def test_save_xml_format(self):
        # Return an object with id for a post(save) request.
        self.http.respond_to(
            'POST', '/stores.xml', self.xml_headers,
            util.to_xml(self.general_store))
        # Return an object for a put request.
        self.http.respond_to(
            'PUT', '/stores/1.xml', self.xml_headers,
            util.to_xml(self.store_update, root='store'))

        self.store.format = formats.XMLFormat
        store = self.store(self.store_new)
        store.save()
        self.assertEqual(self.general_store, store.attributes)
        store.manager_id = 3
        store.save()
开发者ID:drwelby,项目名称:pyactiveresource,代码行数:16,代码来源:activeresource_test.py

示例7: test_find_should_handle_query_params_argument_with_dict_value_to_support_complex_filters

 def test_find_should_handle_query_params_argument_with_dict_value_to_support_complex_filters(self):
     query = urllib.urlencode({'count.gt':5, 'vars[key][]': ['val1', 'val2'], 'name':'xpto'}, True)
     self.http.respond_to(
         'GET', '/people.xml?%s' % query, {},
         util.to_xml([self.arnold], root='people'))
     arnold = self.person.find_first(vars={'key': ['val1', 'val2']}, query_params={'name':'xpto', 'count.gt':5})
     self.assertEqual(self.arnold, arnold.attributes)
开发者ID:wandenberg,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例8: test_get_with_xml_format

 def test_get_with_xml_format(self):
     person = util.to_xml({'id': 1, 'name': 'Matz'}, root='person')
     self.http.respond_to(
         'GET', 'http://localhost/people/1.xml', {}, person)
     self.connection.format = formats.XMLFormat
     response = self.connection.get('/people/1.xml')
     self.assertEqual(response['name'], 'Matz')
开发者ID:varesa,项目名称:pyactiveresource,代码行数:7,代码来源:connection_test.py

示例9: test_find_with_prefix_options

 def test_find_with_prefix_options(self):
     # Paths for prefix_options related requests
     self.http.respond_to("GET", "/stores/1/people.xml", {}, util.to_xml([self.sam], root="people"))
     # Prefix options only
     self.person._site = "http://localhost/stores/$store_id/"
     sam = self.person.find(store_id=1)[0]
     self.assertEqual(self.sam, sam.attributes)
开发者ID:bieli,项目名称:Taskler,代码行数:7,代码来源:activeresource_test.py

示例10: test_find_by_id

    def test_find_by_id(self):
        # Return a single person for a find(id=<id>) call
        self.http.respond_to(
            'GET', '/people/1.xml', {}, util.to_xml(self.arnold, root='person'))

        arnold = self.person.find(1)
        self.assertEqual(self.arnold, arnold.attributes)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:7,代码来源:activeresource_test.py

示例11: test_find_with_query_options

 def test_find_with_query_options(self):
     # Return a single-item people list for a find() call with kwargs
     self.http.respond_to(
         'GET', '/people.xml?name=Arnold', {},
         util.to_xml([self.arnold], root='people'))
     # Query options only
     arnold = self.person.find(name='Arnold')[0]
     self.assertEqual(self.arnold, arnold.attributes)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:8,代码来源:activeresource_test.py

示例12: test_find_with_prefix_and_query_options

 def test_find_with_prefix_and_query_options(self):
     self.http.respond_to(
         'GET', '/stores/1/people.xml?name=Ralph', {},
         util.to_xml([], root='people'))
     # Query & prefix options
     self.person._site = 'http://localhost/stores/$store_id/'
     nobody = self.person.find(store_id=1, name='Ralph')
     self.assertEqual([], nobody)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:8,代码来源:activeresource_test.py

示例13: test_save_should_clear_errors

 def test_save_should_clear_errors(self):
   self.http.respond_to(
       'POST', '/stores.xml', self.xml_headers,
       util.to_xml(self.general_store))
   store = self.store(self.store_new)
   store.errors.add_to_base('bad things!')
   store.save()
   self.assertEqual(0, store.errors.size)
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:8,代码来源:activeresource_test.py

示例14: test_find_one

    def test_find_one(self):
        # Return an object for a specific one-off url
        self.http.respond_to("GET", "/what_kind_of_soup.xml", {}, util.to_xml(self.soup, root="soup"))

        class Soup(activeresource.ActiveResource):
            _site = "http://localhost"

        soup = Soup.find_one(from_="/what_kind_of_soup.xml")
        self.assertEqual(self.soup, soup.attributes)
开发者ID:bieli,项目名称:Taskler,代码行数:9,代码来源:activeresource_test.py

示例15: test_find

    def test_find(self):
        # Return a list of people for a find method call
        self.http.respond_to(
            'GET', '/people.xml', {},
            util.to_xml([self.arnold, self.eb], root='people'))

        people = self.person.find()
        self.assertEqual([self.arnold, self.eb],
                         [p.attributes for p in people])
开发者ID:PiratenBayernIT,项目名称:pyactiveresource,代码行数:9,代码来源:activeresource_test.py


注:本文中的pyactiveresource.util.to_xml函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。