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


Python three.Three类代码示例

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


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

示例1: test_shortened_between_keyword

 def test_shortened_between_keyword(self):
     t = Three("api.city.gov")
     dates = ("03-01-10", "03-05-10")
     t.request("123", between=dates)
     expected = "https://api.city.gov/requests/123.json"
     params = {"start_date": "2010-03-01T00:00:00Z", "end_date": "2010-03-05T00:00:00Z"}
     req.get.assert_called_with(expected, params=params)
开发者ID:siruguri,项目名称:three,代码行数:7,代码来源:test.py

示例2: test_only_start_keyword_arguments

 def test_only_start_keyword_arguments(self):
     t = Three("api.city.gov")
     t.request("456", start="03-01-2010")
     end_date = date.today().strftime("%Y-%m-%dT00:00:00Z")
     expected = "https://api.city.gov/requests/456.json"
     params = {"start_date": "2010-03-01T00:00:00Z", "end_date": end_date}
     req.get.assert_called_with(expected, params=params)
开发者ID:siruguri,项目名称:three,代码行数:7,代码来源:test.py

示例3: test_between_can_handle_datetimes

 def test_between_can_handle_datetimes(self):
     t = Three("api.city.gov")
     dates = (date(2010, 3, 10), date(2010, 3, 15))
     t.request("123", between=dates)
     expected = "https://api.city.gov/requests/123.json"
     params = {"start_date": "2010-03-10T00:00:00Z", "end_date": "2010-03-15T00:00:00Z"}
     req.get.assert_called_with(expected, params=params)
开发者ID:siruguri,项目名称:three,代码行数:7,代码来源:test.py

示例4: test_a_default_post

 def test_a_default_post(self):
     t = Three('api.city.gov', api_key='my_api_key')
     t.post('123', name='Zach Williams', address='85 2nd Street')
     params = {'first_name': 'Zach', 'last_name': 'Williams',
               'service_code': '123', 'address_string': '85 2nd Street',
               'api_key': 'my_api_key'}
     expected = 'https://api.city.gov/requests.json'
     t.session.post.assert_called_with(expected, data=params, files=None)
开发者ID:SeeClickFix,项目名称:three,代码行数:8,代码来源:test.py

示例5: test_between_keyword_argument

 def test_between_keyword_argument(self):
     t = Three('api.city.gov')
     t.request('789', between=['03-01-2010', '03-05-2010'])
     expected = 'https://api.city.gov/requests/789.json'
     params = {
         'start_date': '2010-03-01T00:00:00Z',
         'end_date': '2010-03-05T00:00:00Z'
     }
     t.session.get.assert_called_with(expected, params=params)
开发者ID:SeeClickFix,项目名称:three,代码行数:9,代码来源:test.py

示例6: test_start_and_end_keyword_arguments

 def test_start_and_end_keyword_arguments(self):
     t = Three('api.city.gov')
     t.request('456', start='03-01-2010', end='03-05-2010')
     expected = 'https://api.city.gov/requests/456.json'
     params = {
         'start_date': '2010-03-01T00:00:00Z',
         'end_date': '2010-03-05T00:00:00Z'
     }
     t.session.get.assert_called_with(expected, params=params)
开发者ID:SeeClickFix,项目名称:three,代码行数:9,代码来源:test.py

示例7: test_between_can_handle_datetimes

 def test_between_can_handle_datetimes(self):
     t = Three('api.city.gov')
     dates = (date(2010, 3, 10), date(2010, 3, 15))
     t.request('123', between=dates)
     expected = 'https://api.city.gov/requests/123.json'
     params = {
         'start_date': '2010-03-10T00:00:00Z',
         'end_date': '2010-03-15T00:00:00Z'
     }
     t.session.get.assert_called_with(expected, params=params)
开发者ID:SeeClickFix,项目名称:three,代码行数:10,代码来源:test.py

示例8: test_shortened_between_keyword

 def test_shortened_between_keyword(self):
     t = Three('api.city.gov')
     dates = ('03-01-10', '03-05-10')
     t.request('123', between=dates)
     expected = 'https://api.city.gov/requests/123.json'
     params = {
         'start_date': '2010-03-01T00:00:00Z',
         'end_date': '2010-03-05T00:00:00Z'
     }
     t.session.get.assert_called_with(expected, params=params)
开发者ID:SeeClickFix,项目名称:three,代码行数:10,代码来源:test.py

示例9: test_only_start_keyword_arguments

 def test_only_start_keyword_arguments(self):
     t = Three('api.city.gov')
     t.request('456', start='03-01-2010')
     end_date = date.today().strftime('%Y-%m-%dT00:00:00Z')
     expected = 'https://api.city.gov/requests/456.json'
     params = {
         'start_date': '2010-03-01T00:00:00Z',
         'end_date': end_date
     }
     t.session.get.assert_called_with(expected, params=params)
开发者ID:SeeClickFix,项目名称:three,代码行数:10,代码来源:test.py

示例10: test_a_default_post

 def test_a_default_post(self):
     t = Three("api.city.gov", api_key="my_api_key")
     t.post("123", name="Zach Williams", address="85 2nd Street")
     params = {
         "first_name": "Zach",
         "last_name": "Williams",
         "service_code": "123",
         "address_string": "85 2nd Street",
         "api_key": "my_api_key",
     }
     expected = "https://api.city.gov/requests.json"
     req.post.assert_called_with(expected, data=params)
开发者ID:siruguri,项目名称:three,代码行数:12,代码来源:test.py

示例11: test_post_request_with_api_key_argument

 def test_post_request_with_api_key_argument(self):
     t = Three('http://seeclicktest.com/open311/v2')
     t.post('1627', name='Zach Williams', address='120 Spring St',
            description='Just a test post.', phone='555-5555',
            api_key='my_api_key')
     params = {
         'first_name': 'Zach', 'last_name': 'Williams',
         'description': 'Just a test post.', 'service_code': '1627',
         'address_string': '120 Spring St', 'phone': '555-5555',
         'api_key': 'my_api_key'
     }
     expected = 'http://seeclicktest.com/open311/v2/requests.json'
     t.session.post.assert_called_with(expected, data=params, files=None)
开发者ID:SeeClickFix,项目名称:three,代码行数:13,代码来源:test.py

示例12: test_a_default_post

    def test_a_default_post(self):
        responses.add(responses.POST, 'https://api.city.gov/requests.json',
                  body="""[
                  {
                    "service_request_id":293944,
                    "service_notice":"The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code",
                    "account_id":null
                    }
                  ]""",
                  status=201,
                  content_type='application/json')

        t = Three('api.city.gov', api_key='my_api_key')
        resp = t.post('123', name='Zach Williams', address='85 2nd Street')
        params = {'first_name': 'Zach', 'last_name': 'Williams',
                  'service_code': '123', 'address_string': '85 2nd Street',
                  'api_key': 'my_api_key'}

        assert resp.status_code == 201
开发者ID:codeforamerica,项目名称:three,代码行数:19,代码来源:test.py

示例13: test_reset_method_reconfigures_defaults

 def test_reset_method_reconfigures_defaults(self):
     t = Three("foo.bar")
     self.assertEqual(t.endpoint, "https://foo.bar/")
     t.configure(endpoint="bar.bar")
     self.assertEqual(t.endpoint, "https://bar.bar/")
     t.configure(endpoint="http://baz.bar")
     self.assertEqual(t.endpoint, "http://baz.bar/")
     t.reset()
     self.assertEqual(t.endpoint, "https://foo.bar/")
开发者ID:siruguri,项目名称:three,代码行数:9,代码来源:test.py

示例14: test_post_request_with_api_key_argument

 def test_post_request_with_api_key_argument(self):
     t = Three("http://seeclicktest.com/open311/v2")
     t.post(
         "1627",
         name="Zach Williams",
         address="120 Spring St",
         description="Just a test post.",
         phone="555-5555",
         api_key="my_api_key",
     )
     params = {
         "first_name": "Zach",
         "last_name": "Williams",
         "description": "Just a test post.",
         "service_code": "1627",
         "address_string": "120 Spring St",
         "phone": "555-5555",
         "api_key": "my_api_key",
     }
     expected = "http://seeclicktest.com/open311/v2/requests.json"
     req.post.assert_called_with(expected, data=params)
开发者ID:siruguri,项目名称:three,代码行数:21,代码来源:test.py

示例15: test_specific_service_code

 def test_specific_service_code(self):
     t = Three('api.city.gov')
     t.services('123')
     expected = 'https://api.city.gov/services/123.json'
     t.session.get.assert_called_with(expected, params={})
开发者ID:SeeClickFix,项目名称:three,代码行数:5,代码来源:test.py


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