Commit 729d1ae2 authored by Kryha's avatar Kryha 🐧

Fix KROPYVACH-5J;

parent e42f7df5
Pipeline #51541428 passed with stage
in 1 minute and 36 seconds
......@@ -141,4 +141,7 @@ def image_fields(file):
return {
"h": file['height'],
"w": file['width']
} if file['is_an_image'] else {
"h": 0,
"w": 0
}
......@@ -3,7 +3,7 @@ from django.test import TestCase
from django.utils import timezone
from django.test.client import RequestFactory
from posts.models import Post, Board
from posts.api import board_threads_api
from posts.api import board_threads_api, board_thread_api
class ApiTestCase(TestCase):
......@@ -30,3 +30,42 @@ class ApiTestCase(TestCase):
self.assertEqual(list(response.keys()), ['threads', 'page'])
for thread in response['threads']:
self.assertEqual(thread['no'], post.id)
def test_music_file_api(self):
test_board = Board.objects.get(uri='test')
time = timezone.now()
music_file = {
'error': 0,
'extension': 'mp3',
'file': '1482921680005-0.mp3',
'file_id': '1482921680005-0',
'file_path': 'm/src/files-0.mp3',
'filename': ' .mp3',
'hash': 'asdfkljasdklfjaskldjf',
'is_an_image': False,
'name': ' .mp3',
'size': 605703,
'thumb': 'file',
'thumb_path': 'file',
'thumbheight': 18,
'thumbwidth': 6,
'tmp_name': '/tmp/phpkHYDi8',
'type': 'application/octet-stream'
}
op_post = Post.objects.get(board__uri='test', id=1)
op_post.bump = time
op_post.save()
Post.objects.create(
id=2,
time=time,
board=test_board,
ip='127.0.0.1',
sticky=False,
sage=False,
locked=False,
cycle=False,
thread=1,
files=json.dumps([music_file])
)
request = self.factory.get(f'/test/res/1.json')
json.loads(board_thread_api(request, 'test', 1).content)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment