Initial commit
This commit is contained in:
commit
87084ad35e
4 changed files with 151 additions and 0 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 - 2019 Garmelon
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
0
source/tests/__init__.py
Normal file
0
source/tests/__init__.py
Normal file
63
source/tests/test_message.py
Normal file
63
source/tests/test_message.py
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from yaboli import message
|
||||||
|
|
||||||
|
class TestMessage(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_message(self):
|
||||||
|
m = message.Message({ # older message
|
||||||
|
"edited": None,
|
||||||
|
"deleted": None,
|
||||||
|
"time": 1440104478,
|
||||||
|
"id": "00q5kdu2xd4ao",
|
||||||
|
"sender": {
|
||||||
|
"id": "agent:pxXsVkA4L2s=",
|
||||||
|
"name": "Garmy",
|
||||||
|
"server_id": "heim.1",
|
||||||
|
"server_era": "00q2lx69ur11c",
|
||||||
|
"session_id": "70785873566b41344c32733d-e27e0a924311bc4f",
|
||||||
|
},
|
||||||
|
"content": "I claim this room!"
|
||||||
|
})
|
||||||
|
self.assertEqual(m.id(), "00q5kdu2xd4ao" )
|
||||||
|
self.assertEqual(m.parent(), None )
|
||||||
|
self.assertEqual(m.content(), "I claim this room!" )
|
||||||
|
self.assertEqual(m.sender().user_id(), "agent:pxXsVkA4L2s=" )
|
||||||
|
self.assertEqual(m.time(), 1440104478 )
|
||||||
|
self.assertEqual(m.time_formatted(), "21:01:18" )
|
||||||
|
self.assertEqual(m.time_formatted(date=True), "2015-08-20 21:01:18")
|
||||||
|
self.assertEqual(m.deleted(), False )
|
||||||
|
|
||||||
|
m = message.Message({ # newer message
|
||||||
|
"edited": None,
|
||||||
|
"deleted": None,
|
||||||
|
"time": 1460836596,
|
||||||
|
"id": "01dxs00kvhh4w",
|
||||||
|
"parent": "01dxrya95iark",
|
||||||
|
"sender": {
|
||||||
|
"id": "account:010nrwbcafx8g",
|
||||||
|
"name": "Xyzzy",
|
||||||
|
"server_id": "heim.4",
|
||||||
|
"server_era": "01cwcninm0feo",
|
||||||
|
"session_id": "44514577654132456c746b3d-bcf7c88ae84daebd",
|
||||||
|
"client_address": "9d13:4a20",
|
||||||
|
"is_manager": True,
|
||||||
|
},
|
||||||
|
"content": "Hello."
|
||||||
|
})
|
||||||
|
self.assertEqual(m.id(), "01dxs00kvhh4w" )
|
||||||
|
self.assertEqual(m.parent(), "01dxrya95iark" )
|
||||||
|
self.assertEqual(m.content(), "Hello." )
|
||||||
|
self.assertEqual(m.sender().user_id(), "account:010nrwbcafx8g")
|
||||||
|
self.assertEqual(m.time(), 1460836596 )
|
||||||
|
self.assertEqual(m.time_formatted(), "19:56:36" )
|
||||||
|
self.assertEqual(m.time_formatted(date=True), "2016-04-16 19:56:36" )
|
||||||
|
self.assertEqual(m.deleted(), False )
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
67
source/tests/test_session.py
Normal file
67
source/tests/test_session.py
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from yaboli import session
|
||||||
|
|
||||||
|
class TestSession(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_session(self):
|
||||||
|
s = session.Session({
|
||||||
|
"id": "bot:ZktBH-UfJ7w=",
|
||||||
|
"name": "AssassinBot",
|
||||||
|
"server_era": "01cwcmytc5slc",
|
||||||
|
"server_id": "heim.3",
|
||||||
|
"session_id": "5a6b7442482d55664a37773d-6d4d86ecae939c59"
|
||||||
|
})
|
||||||
|
self.assertEqual(s.session_type(), "bot" )
|
||||||
|
self.assertEqual(s.user_id(), "bot:ZktBH-UfJ7w=" )
|
||||||
|
self.assertEqual(s.session_id(), "5a6b7442482d55664a37773d-6d4d86ecae939c59")
|
||||||
|
self.assertEqual(s.name(), "AssassinBot" )
|
||||||
|
self.assertEqual(s.mentionable(), "AssassinBot" )
|
||||||
|
self.assertEqual(s.listable(5), ("", "Assa…") )
|
||||||
|
self.assertEqual(s.listable(10), ("", "AssassinB…") )
|
||||||
|
self.assertEqual(s.listable(50), ("", "AssassinBot") )
|
||||||
|
self.assertEqual(s.server_id(), "heim.3" )
|
||||||
|
self.assertEqual(s.server_era(), "01cwcmytc5slc" )
|
||||||
|
self.assertEqual(s.is_staff(), False )
|
||||||
|
self.assertEqual(s.is_manager(), False )
|
||||||
|
|
||||||
|
s = session.Session({
|
||||||
|
"id": "account:ZktBH-UfJ7w=",
|
||||||
|
"name": "my h^nds @re typin' wurd$",
|
||||||
|
"server_era": "01cwcmytc5slc",
|
||||||
|
"server_id": "heim.3",
|
||||||
|
"session_id": "5a6b7442482d55664a37773d-6d4d86ecae939c59",
|
||||||
|
"is_staff": True
|
||||||
|
})
|
||||||
|
self.assertEqual(s.session_type(), "account" )
|
||||||
|
self.assertEqual(s.name(), "my h^nds @re typin' wurd$" )
|
||||||
|
self.assertEqual(s.mentionable(), "myh^nds@retypinwurd$" )
|
||||||
|
self.assertEqual(s.listable(5), ("*s", "my…") )
|
||||||
|
self.assertEqual(s.listable(10), ("*s", "my h^nd…") )
|
||||||
|
self.assertEqual(s.listable(50), ("*s", "my h^nds @re typin' wurd$"))
|
||||||
|
self.assertEqual(s.is_staff(), True )
|
||||||
|
self.assertEqual(s.is_manager(), False )
|
||||||
|
|
||||||
|
s = session.Session({
|
||||||
|
"id": "account:ZktBH-UfJ7w=",
|
||||||
|
"name": "greenie",
|
||||||
|
"server_era": "01cwcmytc5slc",
|
||||||
|
"server_id": "heim.3",
|
||||||
|
"session_id": "5a6b7442482d55664a37773d-6d4d86ecae939c59",
|
||||||
|
"is_staff": True,
|
||||||
|
"is_manager": True
|
||||||
|
})
|
||||||
|
self.assertEqual(s.mentionable(), "greenie" )
|
||||||
|
self.assertEqual(s.listable(5), ("*ms", "g…") )
|
||||||
|
self.assertEqual(s.listable(9), ("*ms", "green…") )
|
||||||
|
self.assertEqual(s.listable(10), ("*ms", "greenie"))
|
||||||
|
self.assertEqual(s.is_staff(), True )
|
||||||
|
self.assertEqual(s.is_manager(), True )
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue