Ejemplo n.º 1
0
 def test_change_chat_name(self):
     new_chat_name = CHAT_NAME * 2
     chat_id = Chat.create(CHAT_NAME, CHAT_CODE, CODE_TYPE, CHAT_ACCESS_KEY)
     chat = Chat.get(chat_id)
     chat.set_name(new_chat_name)
     chat = Chat.get(chat_id)
     self.assertEqual(chat.name, MarkdownMixin.decode(new_chat_name))
Ejemplo n.º 2
0
 def __init__(self, **params):
     self.content = params.get('content', "")
     self.author = User.get_login()
     self.chat_link = params.get('chat_link')
     self.parent_link = params.get('parent_link')
     self.message = MarkdownMixin.decode(params.get('message'))
     self.number = Code.get_count_in_chat(params.get('chat_link')) + 1
Ejemplo n.º 3
0
 def test_get_commits_tree_with_single_code(self):
     tree = Code.get_commits_tree(self.chat_id)
     self.assertEqual(tree.get('text').get('name'), 1)
     self.assertEqual(
         tree.get('text').get('title'),
         MarkdownMixin.decode(START_COMMIT_MESSAGE))
     self.assertEqual(tree.get('children'), [])
     self.assertEqual(tree.get('innerHTML'), NODE_MARKUP.format(id=1))
Ejemplo n.º 4
0
 def test_get_root_in_chat_with_single_code(self):
     code = Code.get_root_in_chat(self.chat_id)
     self.assertIsInstance(code, Code)
     self.assertEquals(code.author, USERNAME)
     self.assertEquals(code.content, CHAT_CODE)
     self.assertEquals(code.chat_link, self.chat_id)
     self.assertEquals(code.parent_link, None)
     self.assertEquals(code.message,
                       MarkdownMixin.decode(START_COMMIT_MESSAGE))
Ejemplo n.º 5
0
    def set_name(self, name):
        """Установка названия чата

        :param name: новое название чата
        :return: объект в разных написаниях названия чата: \
            оригинальное, без тегов, экрнированные теги
        """
        self.name = MarkdownMixin.decode(name)
        db.session.commit()
        Message.send_about_change_chat_name(self.id,
                                            MarkdownMixin.plain(self.name))
        return {
            "original": self.name,
            "plain": MarkdownMixin.plain(self.name),
            "escaped": MarkdownMixin.escape_html(self.name)
        }
Ejemplo n.º 6
0
 def test_text_markdown(self):
     self.assertEqual(MarkdownMixin.decode(BASE_TEXT),
                      TEXT_MARKDOWN_DECODED)
Ejemplo n.º 7
0
 def test_find_chat_by_full_name(self):
     search_name = CHAT_NAME
     found_chat_list = Chat.find(search_name)
     self.assertGreaterEqual(len(found_chat_list), 1)
     self.assertEqual(found_chat_list[0].name, MarkdownMixin.decode(CHAT_NAME))
Ejemplo n.º 8
0
 def test_create_chat(self):
     chat = Chat.get(self.chat_id)
     chat_info = chat.get_info()
     self.assertEquals(chat_info.get('name'), MarkdownMixin.decode(CHAT_NAME))
     self.assertEquals(chat_info.get('code_type'), CODE_TYPE)
Ejemplo n.º 9
0
 def __init__(self, name, code_type, access_key):
     self.name = MarkdownMixin.decode(name)
     self.code_type = code_type
     self.access_key = access_key
Ejemplo n.º 10
0
 def __init__(self, content, chat_link, message_type):
     self.content = MarkdownMixin.decode(content)
     self.author = User.get_login()
     self.chat_link = chat_link
     self.type = message_type