1
0
mirror of https://github.com/gryf/slack-backup.git synced 2025-12-17 19:40:21 +01:00

Fix for files object db store

This commit is contained in:
2016-11-26 15:13:43 +01:00
parent 2c6979f2b5
commit 137f9bbac6
2 changed files with 9 additions and 2 deletions

View File

@@ -188,6 +188,7 @@ class Client(object):
data['url_private_download'])
priv_url = data['url_private_download']
message.file.filepath = self.downloader.download(priv_url, 'file')
self.session.add(message.file)
def _att_data(self, message, data):
"""
@@ -229,7 +230,7 @@ class Client(object):
def _update_channel(self, channel, data):
"""Update a channel with provided data"""
logging.info("Update channel `%s' information in DB", channel.name)
logging.info("Update channel `%s' information in DB", data['name'])
channel.update(data)
channel.user = self.q(o.User).filter(o.User.slackid ==

View File

@@ -356,7 +356,9 @@ class FakeArgs(object):
team = 'fake_team'
database = None
channels = None
assets = 'assets'
def __contains__(self, key):
return hasattr(self, key)
class TestApiCalls(TestCase):
@@ -377,6 +379,7 @@ class TestApiCalls(TestCase):
cl = client.Client(FakeArgs())
cl.slack.api_call = MagicMock(return_value=USERS)
cl.downloader._download = MagicMock(return_value=None)
cl.update_users()
cl.slack.api_call = MagicMock(return_value=CHANNELS)
@@ -406,6 +409,7 @@ class TestClient(TestCase):
def test_update_users(self):
cl = client.Client(FakeArgs())
cl.slack.api_call = MagicMock(return_value=USERS)
cl.downloader._download = MagicMock(return_value=None)
cl.update_users()
users = cl.session.query(o.User).all()
self.assertEqual(len(users), 4)
@@ -427,6 +431,7 @@ class TestMessage(TestCase):
self.cl = client.Client(args)
self.cl.downloader.authorize = MagicMock()
self.cl.slack.api_call = MagicMock(return_value=USERS)
self.cl.downloader._download = MagicMock(return_value=None)
self.cl.update_users()
self.cl.slack.api_call = MagicMock(return_value=CHANNELS)
@@ -436,6 +441,7 @@ class TestMessage(TestCase):
def test_update_history(self):
self.cl.downloader._download = MagicMock(return_value=None)
self.cl.slack.api_call.side_effect = [MSGS, MSG3]
self.cl.update_history()
self.assertEqual(len(self.cl.q(o.Message).all()), 5)