Skip to content

Commit 4636b1d

Browse files
authored
Merge pull request #495 from Shopify/melaniew/revert-dynamic-api-version
Revert "Merge pull request #441 from smubbs/dynamic-api-version"
2 parents 92e0e56 + 52b4a6e commit 4636b1d

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
== Unreleased
2+
- Revert Feature #441 Dynamic API Versioning ([#495](https://github.com/Shopify/shopify_python_api/pull/495))
3+
14
== Version 8.3.1
25
- Fix bug: Add the `shopify/utils` sub-package when building the source distribution ([#493](https://github.com/Shopify/shopify_python_api/pull/493))
36

shopify/api_version.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import re
2-
import json
3-
from six.moves.urllib import request
42

53

64
class InvalidVersionError(Exception):
@@ -28,15 +26,13 @@ def define_version(cls, version):
2826

2927
@classmethod
3028
def define_known_versions(cls):
31-
req = request.urlopen("https://app.shopify.com/services/apis.json")
32-
data = json.loads(req.read().decode("utf-8"))
33-
for api in data["apis"]:
34-
if api["handle"] == "admin":
35-
for release in api["versions"]:
36-
if release["handle"] == "unstable":
37-
cls.define_version(Unstable())
38-
else:
39-
cls.define_version(Release(release["handle"]))
29+
cls.define_version(Unstable())
30+
cls.define_version(Release("2020-01"))
31+
cls.define_version(Release("2020-04"))
32+
cls.define_version(Release("2020-07"))
33+
cls.define_version(Release("2020-10"))
34+
cls.define_version(Release("2021-01"))
35+
cls.define_version(Release("2021-04"))
4036

4137
@classmethod
4238
def clear_defined_versions(cls):

test/fixtures/api_version.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/test_helper.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ def setUp(self):
2020
self.http = http_fake.TestHandler
2121
self.http.set_response(Exception("Bad request"))
2222
self.http.site = "https://this-is-my-test-show.myshopify.com"
23-
self.fake(
24-
"apis",
25-
url="https://app.shopify.com/services/apis.json",
26-
method="GET",
27-
code=200,
28-
response_headers={"Content-type": "application/json"},
29-
body=self.load_fixture("api_version"),
30-
has_user_agent=False,
31-
)
3223

3324
def load_fixture(self, name, format="json"):
3425
with open(os.path.dirname(__file__) + "/fixtures/%s.%s" % (name, format), "rb") as f:
@@ -44,10 +35,13 @@ def fake(self, endpoint, **kwargs):
4435
extension = ""
4536
else:
4637
extension = ".%s" % (kwargs.pop("extension", "json"))
47-
if kwargs.get("url"):
48-
url = kwargs.get("url")
49-
else:
50-
url = "https://this-is-my-test-show.myshopify.com%s/%s%s" % (prefix, endpoint, extension)
38+
39+
url = "https://this-is-my-test-show.myshopify.com%s/%s%s" % (prefix, endpoint, extension)
40+
try:
41+
url = kwargs["url"]
42+
except KeyError:
43+
pass
44+
5145
headers = {}
5246
if kwargs.pop("has_user_agent", True):
5347
userAgent = "ShopifyPythonAPI/%s Python/%s" % (shopify.VERSION, sys.version.split(" ", 1)[0])

0 commit comments

Comments
 (0)