Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12d611b

Browse files
authored
Merge pull request Yelp#77 from Yelp/add_test_of_international_biz_lookup
Add test of international biz for business endpoint. Add unicode_lite…
2 parents acf3235 + 501a259 commit 12d611b

24 files changed

+294
-23
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@ repos:
2525
rev: 18.6b4
2626
hooks:
2727
- id: black
28+
- repo: https://github.com/asottile/reorder_python_imports
29+
rev: v1.1.0
30+
hooks:
31+
- id: reorder-python-imports
32+
args:
33+
- --add-import
34+
- from __future__ import absolute_import
35+
- --add-import
36+
- from __future__ import unicode_literals

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
from setuptools import find_packages
36
from setuptools import setup
47

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
import responses
6+
37
from testing.util import read_json_file
48

59

6-
BUSINESS_LOOKUP_RESPONSE = responses.Response(
10+
YELP_SAN_FRANCISCO = responses.Response(
711
method="GET",
812
url="https://api.yelp.com/v3/businesses/yelp-san-francisco",
913
json=read_json_file("business_lookup_yelp_san_francisco.json"),
1014
status=200,
1115
)
16+
17+
18+
SACRE_COEUR_PARIS = responses.Response(
19+
method="GET",
20+
url="https://api.yelp.com/v3/businesses/basilique-du-sacré-cœur-de-montmartre-paris-3", # noqa: E501
21+
json=read_json_file("business_lookup_sacre_coeur_paris.json"),
22+
status=200,
23+
)

testing/error_responses.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
import responses
36

47

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"alias": "basilique-du-sacr\u00e9-c\u0153ur-de-montmartre-paris-3",
3+
"categories": [
4+
{
5+
"alias": "churches",
6+
"title": "\u00c9glise"
7+
},
8+
{
9+
"alias": "landmarks",
10+
"title": "Lieu & B\u00e2timent historique"
11+
}
12+
],
13+
"coordinates": {
14+
"latitude": 48.886720769013,
15+
"longitude": 2.3430021056794
16+
},
17+
"display_phone": "01 53 41 89 00",
18+
"hours": [
19+
{
20+
"hours_type": "REGULAR",
21+
"is_open_now": false,
22+
"open": [
23+
{
24+
"day": 0,
25+
"end": "2230",
26+
"is_overnight": false,
27+
"start": "0600"
28+
},
29+
{
30+
"day": 1,
31+
"end": "2230",
32+
"is_overnight": false,
33+
"start": "0600"
34+
},
35+
{
36+
"day": 2,
37+
"end": "2230",
38+
"is_overnight": false,
39+
"start": "0600"
40+
},
41+
{
42+
"day": 3,
43+
"end": "2230",
44+
"is_overnight": false,
45+
"start": "0600"
46+
},
47+
{
48+
"day": 4,
49+
"end": "2230",
50+
"is_overnight": false,
51+
"start": "0600"
52+
},
53+
{
54+
"day": 5,
55+
"end": "2230",
56+
"is_overnight": false,
57+
"start": "0600"
58+
},
59+
{
60+
"day": 6,
61+
"end": "2230",
62+
"is_overnight": false,
63+
"start": "0600"
64+
}
65+
]
66+
}
67+
],
68+
"id": "spIGAtquYQ0S7xai5eJSuA",
69+
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/_jdFMkxKj8ejkD2dOduC1A/o.jpg",
70+
"is_claimed": false,
71+
"is_closed": false,
72+
"location": {
73+
"address1": "35 rue du Chevalier de la Barre",
74+
"address2": "",
75+
"address3": "",
76+
"city": "Paris",
77+
"country": "FR",
78+
"cross_streets": "",
79+
"display_address": [
80+
"35 rue du Chevalier de la Barre",
81+
"75018 Paris"
82+
],
83+
"state": "75",
84+
"zip_code": "75018"
85+
},
86+
"name": "Basilique du Sacr\u00e9-C\u0153ur de Montmartre",
87+
"phone": "+33153418900",
88+
"photos": [
89+
"https://s3-media2.fl.yelpcdn.com/bphoto/_jdFMkxKj8ejkD2dOduC1A/o.jpg",
90+
"https://s3-media4.fl.yelpcdn.com/bphoto/xFFrnrUAPZYFvtZMLLWkvQ/o.jpg",
91+
"https://s3-media4.fl.yelpcdn.com/bphoto/70tWE7016eFJ-xjTup-YRA/o.jpg"
92+
],
93+
"rating": 4.5,
94+
"review_count": 538,
95+
"transactions": [],
96+
"url": "https://www.yelp.fr/biz/basilique-du-sacr%C3%A9-c%C5%93ur-de-montmartre-paris-3"
97+
}

testing/obj/business.py

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
from yelp.obj.business import Business
3-
from yelp.obj.location import Location
4-
from yelp.obj.coordinates import Coordinates
56
from yelp.obj.category import Category
6-
from yelp.obj.hours import Hours
7+
from yelp.obj.coordinates import Coordinates
78
from yelp.obj.hours import DayHours
9+
from yelp.obj.hours import Hours
10+
from yelp.obj.location import Location
811

912

10-
biz_response_obj = Business(
13+
yelp_san_francisco = Business(
1114
id="4kMBvIEWPxWkWKFN__8SxQ",
1215
alias="yelp-san-francisco",
1316
name="Yelp",
@@ -53,3 +56,56 @@
5356
transactions=[],
5457
attributes=None,
5558
)
59+
60+
61+
sacre_coeur_paris = Business(
62+
alias="basilique-du-sacré-cœur-de-montmartre-paris-3",
63+
attributes=None,
64+
categories=[
65+
Category(alias="churches", title="Église"),
66+
Category(alias="landmarks", title="Lieu & Bâtiment historique"),
67+
],
68+
coordinates=Coordinates(latitude=48.886720769013, longitude=2.3430021056794),
69+
display_phone="01 53 41 89 00",
70+
hours=[
71+
Hours(
72+
hours_type="REGULAR",
73+
is_open_now=False,
74+
open=[
75+
DayHours(day=0, end="2230", is_overnight=False, start="0600"),
76+
DayHours(day=1, end="2230", is_overnight=False, start="0600"),
77+
DayHours(day=2, end="2230", is_overnight=False, start="0600"),
78+
DayHours(day=3, end="2230", is_overnight=False, start="0600"),
79+
DayHours(day=4, end="2230", is_overnight=False, start="0600"),
80+
DayHours(day=5, end="2230", is_overnight=False, start="0600"),
81+
DayHours(day=6, end="2230", is_overnight=False, start="0600"),
82+
],
83+
)
84+
],
85+
id="spIGAtquYQ0S7xai5eJSuA",
86+
image_url="https://s3-media2.fl.yelpcdn.com/bphoto/_jdFMkxKj8ejkD2dOduC1A/o.jpg",
87+
is_claimed=False,
88+
is_closed=False,
89+
location=Location(
90+
address1="35 rue du Chevalier de la Barre",
91+
address2="",
92+
address3="",
93+
city="Paris",
94+
country="FR",
95+
cross_streets="",
96+
display_address=["35 rue du Chevalier de la Barre", "75018 Paris"],
97+
state="75",
98+
zip_code="75018",
99+
),
100+
name="Basilique du Sacré-Cœur de Montmartre",
101+
phone="+33153418900",
102+
photos=[
103+
"https://s3-media2.fl.yelpcdn.com/bphoto/_jdFMkxKj8ejkD2dOduC1A/o.jpg",
104+
"https://s3-media4.fl.yelpcdn.com/bphoto/xFFrnrUAPZYFvtZMLLWkvQ/o.jpg",
105+
"https://s3-media4.fl.yelpcdn.com/bphoto/70tWE7016eFJ-xjTup-YRA/o.jpg",
106+
],
107+
rating=4.5,
108+
review_count=538,
109+
transactions=[],
110+
url="https://www.yelp.fr/biz/basilique-du-sacr%C3%A9-c%C5%93ur-de-montmartre-paris-3", # noqa: E501
111+
)

testing/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
import json
36
import os.path
47

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
import responses
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
35
import pytest
6+
import responses
47

58

69
@pytest.fixture(autouse=True)

tests/endpoint/business_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
25
import mock
6+
import pytest
37

4-
from yelp.endpoint.business import BusinessEndpoints
58
import yelp.endpoint.business
6-
import pytest
9+
from yelp.endpoint.business import BusinessEndpoints
710

811

912
@pytest.fixture

tests/endpoint/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
5+
import mock
26
import pytest
3-
from yelp.client import Client
7+
48
import yelp.client
5-
import mock
9+
from yelp.client import Client
610

711

812
@pytest.fixture

0 commit comments

Comments
 (0)