-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.py
59 lines (47 loc) · 1.31 KB
/
api_test.py
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
import requests
import shopify
from api import API
from typing import List
import mysql.connector as sql
def get_blogs() -> dict:
""" Gets ID and Title of all blogs
Args:
N/A
Returns:
(dict) of blog info {title:id}
"""
r = requests.get(API.BLOG_URL)
print(r.status_code)
blogs = {}
# print(r_get_blogs.status_code,r_get_blogs.json())
for blog in r.json()['blogs']:
blogs['title'] = blog['id']
return blogs
def get_blog_id_by_title(title: str) -> int:
""" Gets blog ID given a title
Args:
title (str): title of blog to get
Returns:
(int) the ID of the blog
"""
return get_blogs().
def get_articles() -> List[List]:
"""
"""
pass
def post_articles(blog_id: str, data: dict):
"""
"""
r = requests.post(API.ARTICLE_URL_post(API.ADMIN_URL,blog_id),json={'article':data})
return r
if __name__ == '__main__':
# data = {
# "title": "API test",
# "author": "John Luong",
# "tags": "api, tag1, tag2",
# "body_html": "<h1>api test post</h1>\n<p><strong>YEET</strong></p>",
# "published_at": "Thu Mar 24 15:45:47 UTC 2011"
# }
# blog_id = ""
# print(post_articles(blog_id,data).status_code)
print(get_blogs())