feat: Update default caption style to `on_screen_text_top`, add caption style aliases in video renderer, and remove `test_oneup_service.py`.
Browse files
src/video_renderer.py
CHANGED
|
@@ -1064,9 +1064,13 @@ class VideoRenderer:
|
|
| 1064 |
|
| 1065 |
styles = {
|
| 1066 |
"caption_1": (caption_style_1, 3),
|
|
|
|
| 1067 |
"caption_2": (caption_style_2, 3),
|
|
|
|
| 1068 |
"caption_3": (caption_style_3, 3),
|
|
|
|
| 1069 |
"caption_4": (caption_style_4, 3),
|
|
|
|
| 1070 |
"caption_style_on_screen_text": (caption_style_on_screen_text, 3),
|
| 1071 |
"caption_style_on_screen_text_top": (caption_style_on_screen_text_top, 3),
|
| 1072 |
}
|
|
|
|
| 1064 |
|
| 1065 |
styles = {
|
| 1066 |
"caption_1": (caption_style_1, 3),
|
| 1067 |
+
"caption_style_1": (caption_style_1, 3),
|
| 1068 |
"caption_2": (caption_style_2, 3),
|
| 1069 |
+
"caption_style_2": (caption_style_2, 3),
|
| 1070 |
"caption_3": (caption_style_3, 3),
|
| 1071 |
+
"caption_style_3": (caption_style_3, 3),
|
| 1072 |
"caption_4": (caption_style_4, 3),
|
| 1073 |
+
"caption_style_4": (caption_style_4, 3),
|
| 1074 |
"caption_style_on_screen_text": (caption_style_on_screen_text, 3),
|
| 1075 |
"caption_style_on_screen_text_top": (caption_style_on_screen_text_top, 3),
|
| 1076 |
}
|
tests/test_oneup_service.py
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
import sys
|
| 3 |
-
import os
|
| 4 |
-
import unittest
|
| 5 |
-
from unittest.mock import MagicMock, patch
|
| 6 |
-
|
| 7 |
-
# Add parent directory to path
|
| 8 |
-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 9 |
-
|
| 10 |
-
from social_media_publishers.oneup_service import OneUpService
|
| 11 |
-
|
| 12 |
-
class TestOneUpService(unittest.TestCase):
|
| 13 |
-
|
| 14 |
-
def setUp(self):
|
| 15 |
-
# Mock the OneUpClient inside OneUpService
|
| 16 |
-
with patch('social_media_publishers.oneup_service.OneUpClient') as MockClient:
|
| 17 |
-
self.mock_client = MockClient.return_value
|
| 18 |
-
self.service = OneUpService()
|
| 19 |
-
# Restore the mock to the instance for assertion
|
| 20 |
-
self.service.client = self.mock_client
|
| 21 |
-
|
| 22 |
-
@patch('os.path.exists')
|
| 23 |
-
@patch('social_media_publishers.oneup_service.upload_file_to_gcs')
|
| 24 |
-
def test_publish_video_with_identifier(self, mock_upload, mock_exists):
|
| 25 |
-
mock_exists.return_value = True
|
| 26 |
-
# Setup Mocks
|
| 27 |
-
self.mock_client.find_account.return_value = {
|
| 28 |
-
'social_network_id': '12345',
|
| 29 |
-
'social_network_name': 'Test Account',
|
| 30 |
-
'category_id': '999'
|
| 31 |
-
}
|
| 32 |
-
self.mock_client.schedule_video_post.return_value = {
|
| 33 |
-
'message': 'Scheduled successfully',
|
| 34 |
-
'error': False
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
# Scenario: Local file path provided (mocking upload)
|
| 38 |
-
mock_upload.return_value = {'signed_url': 'http://public.url/video.mp4'}
|
| 39 |
-
|
| 40 |
-
metadata = {'title': 'Test Video', 'description': 'Description'}
|
| 41 |
-
|
| 42 |
-
result = self.service.publish_video(
|
| 43 |
-
platform='instagram',
|
| 44 |
-
content_path='/tmp/video.mp4',
|
| 45 |
-
metadata=metadata,
|
| 46 |
-
account_identifier='test_user'
|
| 47 |
-
)
|
| 48 |
-
|
| 49 |
-
# Assertions
|
| 50 |
-
self.assertTrue(result['success'])
|
| 51 |
-
self.mock_client.find_account.assert_called_with('instagram', 'test_user')
|
| 52 |
-
mock_upload.assert_called()
|
| 53 |
-
self.mock_client.schedule_video_post.assert_called_with(
|
| 54 |
-
category_id='999',
|
| 55 |
-
social_network_ids=['12345'],
|
| 56 |
-
video_url='http://public.url/video.mp4',
|
| 57 |
-
title='Test Video',
|
| 58 |
-
content='Description',
|
| 59 |
-
publish_now=True
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
def test_publish_video_account_not_found(self):
|
| 63 |
-
self.mock_client.find_account.return_value = None
|
| 64 |
-
|
| 65 |
-
result = self.service.publish_video(
|
| 66 |
-
platform='instagram',
|
| 67 |
-
content_path='/tmp/video.mp4',
|
| 68 |
-
metadata={},
|
| 69 |
-
account_identifier='unknown_user'
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
self.assertIn('error', result)
|
| 73 |
-
self.assertIn('not found', result['error'])
|
| 74 |
-
|
| 75 |
-
@patch('os.path.exists')
|
| 76 |
-
@patch('social_media_publishers.oneup_service.upload_file_to_gcs')
|
| 77 |
-
def test_publish_video_fallback_category(self, mock_upload, mock_exists):
|
| 78 |
-
mock_exists.return_value = True
|
| 79 |
-
# Scenario: Account found but has no category_id in object, need fallback
|
| 80 |
-
self.mock_client.find_account.return_value = {
|
| 81 |
-
'social_network_id': '12345',
|
| 82 |
-
'social_network_name': 'Test Account',
|
| 83 |
-
# No category_id here
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
# Mock get_categories
|
| 87 |
-
self.mock_client.get_categories.return_value = [{'id': '888', 'category_name': 'Default'}]
|
| 88 |
-
|
| 89 |
-
mock_upload.return_value = {'signed_url': 'http://public.url/video.mp4'}
|
| 90 |
-
self.mock_client.schedule_video_post.return_value = {'message': 'OK'}
|
| 91 |
-
|
| 92 |
-
# Test Direct URL (metadata has it)
|
| 93 |
-
result = self.service.publish_video(
|
| 94 |
-
platform='youtube',
|
| 95 |
-
content_path=None,
|
| 96 |
-
metadata={'video_url': 'http://direct.url/vid.mp4'},
|
| 97 |
-
account_identifier='test_user'
|
| 98 |
-
)
|
| 99 |
-
|
| 100 |
-
self.mock_client.get_categories.assert_called()
|
| 101 |
-
self.mock_client.schedule_video_post.assert_called_with(
|
| 102 |
-
category_id='888',
|
| 103 |
-
social_network_ids=['12345'],
|
| 104 |
-
video_url='http://direct.url/vid.mp4',
|
| 105 |
-
title='',
|
| 106 |
-
content='',
|
| 107 |
-
publish_now=True
|
| 108 |
-
)
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
if __name__ == '__main__':
|
| 112 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workflow_env/full_ai_video_generate_workflow.env
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
JOB_INDEX=0
|
| 2 |
TOTAL_JOBS=1
|
| 3 |
-
CAPTION_STYLE=
|
| 4 |
GCS_BUCKET_NAME=infloxa
|
| 5 |
GCS_BUCKET_FOLDER_NAME=test_xai_product_video
|
| 6 |
GENERATION_COUNT=1
|
|
|
|
| 1 |
JOB_INDEX=0
|
| 2 |
TOTAL_JOBS=1
|
| 3 |
+
CAPTION_STYLE=caption_style_on_screen_text_top
|
| 4 |
GCS_BUCKET_NAME=infloxa
|
| 5 |
GCS_BUCKET_FOLDER_NAME=test_xai_product_video
|
| 6 |
GENERATION_COUNT=1
|