From 537cdb30c3b257a57f61e58e83fc9ed9e61431b3 Mon Sep 17 00:00:00 2001 From: ReimarBauer Date: Mon, 13 May 2024 18:05:29 +0200 Subject: [PATCH] improved --- mslib/mscolab/file_manager.py | 3 +-- mslib/mscolab/utils.py | 8 +------- tests/_test_mscolab/test_utils.py | 8 ++------ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/mslib/mscolab/file_manager.py b/mslib/mscolab/file_manager.py index 92edc0e65..e1a61f979 100644 --- a/mslib/mscolab/file_manager.py +++ b/mslib/mscolab/file_manager.py @@ -31,7 +31,6 @@ import git import threading from sqlalchemy.exc import IntegrityError -from mslib.mscolab.utils import created_at_isoformat from mslib.mscolab.models import db, Operation, Permission, User, Change, Message from mslib.mscolab.conf import mscolab_settings @@ -400,7 +399,7 @@ def get_all_changes(self, op_id, user, named_version=False): 'comment': change.comment, 'version_name': change.version_name, 'username': change.user.username, - 'created_at': created_at_isoformat(change.created_at) + 'created_at': change.created_at.isoformat() }, changes)) def get_change_content(self, ch_id, user): diff --git a/mslib/mscolab/utils.py b/mslib/mscolab/utils.py index b045c48d8..865297939 100644 --- a/mslib/mscolab/utils.py +++ b/mslib/mscolab/utils.py @@ -55,16 +55,10 @@ def get_message_dict(message): "message_type": message.message_type, "reply_id": message.reply_id, "replies": [], - "time": created_at_isoformat(message.created_at) + "time": message.created_at.isoformat() } -def created_at_isoformat(created_at): - if created_at is None: - return None - return created_at.isoformat() - - def os_fs_create_dir(directory_path): if '://' in directory_path: try: diff --git a/tests/_test_mscolab/test_utils.py b/tests/_test_mscolab/test_utils.py index 42b79bdf6..a801a7a29 100644 --- a/tests/_test_mscolab/test_utils.py +++ b/tests/_test_mscolab/test_utils.py @@ -26,14 +26,13 @@ import os import pytest import json -import datetime from fs.tempfs import TempFS from mslib.mscolab.conf import mscolab_settings from mslib.mscolab.models import Operation, MessageType from mslib.mscolab.seed import add_user, get_user from mslib.mscolab.utils import (get_recent_op_id, get_session_id, - get_message_dict, created_at_isoformat, create_files, + get_message_dict, create_files, os_fs_create_dir) @@ -49,7 +48,7 @@ class user: replies = [] class created_at: - def strftime(value): + def isoformat(): pass @@ -83,9 +82,6 @@ def test_get_message_dict(self): result = get_message_dict(Message()) assert result["message_type"] == MessageType.TEXT - def test_created_at_isoformat(self): - now = datetime.datetime.now(datetime.timezone.utc) - assert now.isoformat() == created_at_isoformat(now) def test_os_fs_create_dir(self): _fs = TempFS(identifier="msui")