Save test response to json file

List public and all
This commit is contained in:
simonwt 2026-04-01 00:00:04 +01:00
parent 5e477c53cb
commit 9407b9a03e
7 changed files with 96 additions and 30 deletions

View file

@ -14,7 +14,7 @@ if not os.getenv("client_id") or not os.getenv("client_secret"):
API = APIClient(
client_id=os.getenv("client_id"),
client_secret=os.getenv("client_secret"),
debug=True
debug=False # Set to True to enable debug output
)
# Keep a token cache to avoid unnecessary sign-ins during development.
@ -29,7 +29,11 @@ if os.path.exists("token_data.json"):
if not API.is_token_valid():
tokendata = API.sign_in()
with open("token_data.json", "w") as f:
json.dump(tokendata, f, indent=4)
json.dump(tokendata, f, indent=2)
def save_response(response):
with open("test_output.json", "w") as f:
json.dump(response, f, indent=2)
# print("-----------Get a user profile----------------")
# profile = API.run_job('userprofile.get', "simon-little")
@ -47,7 +51,8 @@ if not API.is_token_valid():
# feed = API.run_job('post.listbyuserprofile', "simon-little")
# print(feed)
# print("-----------------------------")
# post = API.run_job('post.create', {
# save_response(API.run_job('post.create', {
# "blurLabel": None,
# "cardUrl": None,
# "postText": "This is a test post created via the API wrapper.",
@ -56,11 +61,9 @@ if not API.is_token_valid():
# "pk": "maintrunk#maintrunk",
# "sk": "maintrunk#maintrunk"
# }
# })
# print(post)
# print("-----------------------------")
# }))
# post = API.run_job('comment.create', {
# save_response(API.run_job('comment.create', {
# "blurLabel": None,
# "commentText": "This is a test comment created via the API wrapper.",
# "parent": {
@ -73,12 +76,10 @@ if not API.is_token_valid():
# "sk": "post#1774951384-98fe38df"
# },
# "version": 3
# })
# print(post)
# print("-----------------------------")
# feed = API.run_job('comment.listtbypostid', "1774951384-98fe38df")
# print(feed)
# print("-----------------------------")
# }))
# save_response(API.run_job('comment.listtbypostid', "1774951384-98fe38df"))
# x = 1
# while x <= 20:
# post = API.run_job('comment.create', {
@ -97,19 +98,17 @@ if not API.is_token_valid():
# })
# print(post)
# x += 1
# print("-----------------------------")
# notifications = API.run_job('notification.listnotifications')
# print(notifications)
# print("-----------------------------")
# feed = API.run_job('feed.cafefeed')
# print(feed)
# print("-----------------------------")
# feed = API.run_job('feed.followingfeed')
# print(feed)
# print("-----------------------------")
feed = API.run_job('feed.followingfeed', {
'pk': 'maintrunk#maintrunk',
'sk': 'post#1774951384-98fe38df'
})
print(feed)
print("-----------------------------")
# save_response(API.run_job('notification.listnotifications'))
# save_response(API.run_job('feed.cafefeed'))
# save_response(API.run_job('feed.followingfeed'))
# save_response(API.run_job('feed.followingfeed', {
# 'pk': 'maintrunk#maintrunk',
# 'sk': 'post#1774951384-98fe38df'
# }))
save_response(API.run_job('post.listall'))