-
Notifications
You must be signed in to change notification settings - Fork 3
/
fetch_example_json.py
executable file
·99 lines (78 loc) · 2.69 KB
/
fetch_example_json.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python3
import os
import shutil
from lowerpines.endpoints.block import Block
from lowerpines.endpoints.bot import Bot
from lowerpines.endpoints.group import Group
from lowerpines.exceptions import NoneFoundException
from lowerpines.gmi import get_gmi
IMPORT_ERROR_TEXT = "To use this script create a 'test_access_token.py' file with a TEST_ACCESS_TOKEN value"
try:
# noinspection PyUnresolvedReferences
from test_access_token import TEST_ACCESS_TOKEN # type: ignore
except ModuleNotFoundError:
print(IMPORT_ERROR_TEXT)
exit(1)
except ImportError:
print(IMPORT_ERROR_TEXT)
exit(1)
TEST_DATA_FOLDER = "test_data"
allow_non_deterministic = True
if __name__ == "__main__":
gmi = get_gmi(TEST_ACCESS_TOKEN)
gmi.write_json_to = TEST_DATA_FOLDER
if os.path.exists(TEST_DATA_FOLDER):
shutil.rmtree(TEST_DATA_FOLDER)
test_bot = None
test_group = None
if allow_non_deterministic:
TEST_GROUP_NAME = "TestGroup"
try:
test_group = gmi.groups.get(name=TEST_GROUP_NAME)
except NoneFoundException:
test_group = Group(
gmi,
name=TEST_GROUP_NAME,
description="Here is the description",
image_url="https://i.groupme.com/750x700.jpeg.bda7c13e72f00b58193bd6af2114cb24c3919d1a",
)
test_group.save()
TEST_BOT_NAME = "TestBot"
try:
test_bot = test_group.bots.get(name=TEST_BOT_NAME)
except NoneFoundException:
test_bot = Bot(
gmi,
group_id=test_group.group_id,
name=TEST_BOT_NAME,
callback_url="http://example.com",
avatar_url="https://i.groupme.com/750x700.jpeg.bda7c13e72f00b58193bd6af2114cb24c3919d1a",
dm_notification=False,
)
test_bot.save()
test_bot.save()
test_group.save()
test_group.refresh()
test_bot.post("BotMessage")
test_group.post("UserMessage")
message = test_group.messages.recent()[0]
message.like()
message.refresh()
gmi.user.get().enable_sms(15, "test")
gmi.user.get().disable_sms()
gmi.user.get().save()
gmi.refresh()
gmi.user.filter()
gmi.groups.filter()
gmi.groups.former()
gmi.bots.filter()
gmi.chats.filter()
my_user_id = gmi.user.get().user_id
Block(gmi).get_all(my_user_id)
Block.block(gmi, my_user_id, "6911718")
Block.block_exists(gmi, my_user_id, "6911718")
if allow_non_deterministic:
if test_bot is not None:
test_bot.delete()
if test_group is not None:
test_group.delete()