forked from Shopify/shopify_python_api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle_test.py
More file actions
75 lines (62 loc) · 3.03 KB
/
article_test.py
File metadata and controls
75 lines (62 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import shopify
from test.test_helper import TestCase
class ArticleTest(TestCase):
def test_create_article(self):
self.fake(
"blogs/1008414260/articles",
method="POST",
body=self.load_fixture("article"),
headers={"Content-type": "application/json"},
)
article = shopify.Article({"blog_id": 1008414260})
article.save()
self.assertEqual("First Post", article.title)
def test_get_article(self):
self.fake("articles/6242736", method="GET", body=self.load_fixture("article"))
article = shopify.Article.find(6242736)
self.assertEqual("First Post", article.title)
def test_update_article(self):
self.fake("articles/6242736", method="GET", body=self.load_fixture("article"))
article = shopify.Article.find(6242736)
self.fake(
"articles/6242736",
method="PUT",
body=self.load_fixture("article"),
headers={"Content-type": "application/json"},
)
article.save()
def test_get_articles(self):
self.fake("articles", method="GET", body=self.load_fixture("articles"))
articles = shopify.Article.find()
self.assertEqual(3, len(articles))
def test_get_articles_namespaced(self):
self.fake("blogs/1008414260/articles", method="GET", body=self.load_fixture("articles"))
articles = shopify.Article.find(blog_id=1008414260)
self.assertEqual(3, len(articles))
def test_get_article_namespaced(self):
self.fake("blogs/1008414260/articles/6242736", method="GET", body=self.load_fixture("article"))
article = shopify.Article.find(6242736, blog_id=1008414260)
self.assertEqual("First Post", article.title)
def test_get_authors(self):
self.fake("articles/authors", method="GET", body=self.load_fixture("authors"))
authors = shopify.Article.authors()
self.assertEqual("Shopify", authors[0])
self.assertEqual("development shop", authors[-1])
def test_get_authors_for_blog_id(self):
self.fake("blogs/1008414260/articles/authors", method="GET", body=self.load_fixture("authors"))
authors = shopify.Article.authors(blog_id=1008414260)
self.assertEqual(3, len(authors))
def test_get_tags(self):
self.fake("articles/tags", method="GET", body=self.load_fixture("tags"))
tags = shopify.Article.tags()
self.assertEqual("consequuntur", tags[0])
self.assertEqual("repellendus", tags[-1])
def test_get_tags_for_blog_id(self):
self.fake("blogs/1008414260/articles/tags", method="GET", body=self.load_fixture("tags"))
tags = shopify.Article.tags(blog_id=1008414260)
self.assertEqual("consequuntur", tags[0])
self.assertEqual("repellendus", tags[-1])
def test_get_popular_tags(self):
self.fake("articles/tags.json?limit=1&popular=1", extension=False, method="GET", body=self.load_fixture("tags"))
tags = shopify.Article.tags(popular=1, limit=1)
self.assertEqual(3, len(tags))