seitime-frappe/frappe/chat/util/test_util.py
Achilles Rasquinha 005cfe3dc8 🎉 NEW Frappe Chat (#4612)
* added doctypes, created frappe chat ui

* added component layout with state-like abilities, added apis

* updated user doctype, moved from state-like feature and component abstraction

* added room component

* fixed publish_realtime with after_commit = True

* created room component and searchbar

* minor fix

* functional message parsing

* update

* Added Chat Profile

* added chat message

* more changes into chat room

* fixed APIs, added client side scripting

* added chat message attachements, more doc updates

* Brand New UI with socket io room integration

* completed socketio integration. off to room subscription and publish

* realtime room update

* raw update

* initialized docs, added p2p connection for call tests

* updated docs

* added coverage, updated api for ease of use

* raw commit

* added test cases

* Chat Room updates and new room creation

* added chat group creation

* added collapsible plugin

* toggable room view

* updated

* [RAW]

* updated UI for chat

* Deleted Previous Chat Page

* moved from frappe.Chat.Widget to frappe.Chat

* modularized frappe-fab

* added more docstrings

* tried adding conversation tones

* Added conversation_tones and refurbished chat popper

* modified frappe.ui.Dialog, moved from AppBar to ActionBar, responsive for Mobile 💃

* moved RoomList item namespace

* Configurable Desktop update, moved profile updates to on_update

* added state change listeners

* removed AppBar to ActionBar customizable 💃

* added destroy method

* removed coverage, refactored group creation

* Successful Chat Rooms and Group creation

* sort rows based on last_message_timestamp or creation

* added frappe._.compare

* removed redundant less variables

* Chat Room back button with custom routing and destroy methods

* Added EmojiPicker

* fixed multiple dialog render

* setup quick access

* added chat chime, functional chat message list updates at room list

* deleted package-lock.json

* realtime date updates

* updated chat message list

* functional message render and updates

* added track seen

* added typing status

* updated typing status

* valid typing statuses and quick search

* Functional Quick Search

* reverted fix

* some more cleanup and promisifed

* fixed hints close on click

* updated fab boldness

* close popper on click panel

* close popper on click panel

* reverted octicon-lg, fixed popper heading click

* new frappe capture

* removed webcamjs

* added uploader and capture

* removed chat FAB, added as notification instead

* on message update
2017-12-28 18:58:43 +05:30

35 lines
No EOL
875 B
Python

# imports - standard imports
import unittest
# imports - module imports
from frappe.chat.util import (
get_user_doc,
safe_json_loads
)
import frappe
class TestChatUtil(unittest.TestCase):
def test_safe_json_loads(self):
number = safe_json_loads("1")
self.assertEquals(type(number), int)
number = safe_json_loads("1.0")
self.assertEquals(type(number), float)
string = safe_json_loads("foobar")
self.assertEquals(type(string), str)
array = safe_json_loads('[{ "foo": "bar" }]')
self.assertEquals(type(array), list)
objekt = safe_json_loads('{ "foo": "bar" }')
self.assertEquals(type(objekt), dict)
true, null = safe_json_loads("true", "null")
self.assertEquals(true, True)
self.assertEquals(null, None)
def test_get_user_doc(self):
# Needs more test cases.
user = get_user_doc()
self.assertEquals(user.name, frappe.session.user)