Skip to content

Commit

Permalink
improved
Browse files Browse the repository at this point in the history
  • Loading branch information
ReimarBauer committed May 13, 2024
1 parent a79804e commit 537cdb3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions mslib/mscolab/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
8 changes: 1 addition & 7 deletions mslib/mscolab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions tests/_test_mscolab/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -49,7 +48,7 @@ class user:
replies = []

class created_at:
def strftime(value):
def isoformat():
pass


Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 537cdb3

Please sign in to comment.