-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# build-and-push.yml | ||
|
||
name: Build and Push Docker Image | ||
|
||
on: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# lint-markdown.yml | ||
|
||
--- | ||
name: Markdown Lint | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# .markdownlint.yaml | ||
|
||
--- | ||
MD013: false | ||
default: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# .pre-commit-config.yaml | ||
|
||
--- | ||
repos: | ||
- hooks: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# app/__init__.py | ||
# __init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# app/bot.py | ||
# bot.py | ||
|
||
import asyncio | ||
import logging | ||
from aiogram import Bot, Dispatcher, types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# app/download.py | ||
# download.py | ||
|
||
import os | ||
import logging | ||
import yt_dlp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# app/main.py | ||
# main.py | ||
|
||
import logging | ||
import asyncio | ||
from fastapi import FastAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# docker-compose.yml | ||
|
||
--- | ||
networks: | ||
traefik_default: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# default.conf | ||
|
||
server { | ||
listen 80; | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# pytest.ini | ||
|
||
[pytest] | ||
testpaths = tests | ||
addopts = --ignore=lib/python3.11/site-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# | ||
# __init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# test_api.py | ||
|
||
import pytest | ||
from httpx import AsyncClient | ||
from app.main import app | ||
|
||
@pytest.mark.asyncio | ||
async def test_process_url(): | ||
async with AsyncClient(app=app, base_url="http://test") as ac: | ||
response = await ac.post("/process_url/", json={"url": "https://example.com"}) | ||
assert response.status_code == 200 | ||
assert response.json()["status"] == "success" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# test_bot.py | ||
|
||
import pytest | ||
from aiogram.types import Message | ||
from app.bot import handle_message | ||
|
||
@pytest.mark.asyncio | ||
async def test_handle_message(): | ||
class MockMessage: | ||
text = "https://example.com" | ||
async def reply(self, text): | ||
assert "Unsupported URL https://example.com/" in text or "success" in text | ||
|
||
message = MockMessage() | ||
await handle_message(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# test_url_processing.py | ||
|
||
import os | ||
import pytest | ||
from unittest.mock import patch, AsyncMock | ||
from app.url_processing import process_url_request, transform_tiktok_url | ||
|
||
@pytest.mark.asyncio | ||
async def test_tiktok_url_processing(): | ||
test_url = "https://vt.tiktok.com/ZSYFmgDeS/" | ||
expected_file_path = "/tmp/url-fairy-bot-cache/https___www_tiktok_com___video_7371578973689482539.mp4" | ||
transformed_url = transform_tiktok_url("https://www.tiktok.com/video/7371578973689482539") | ||
|
||
# Mock follow_redirects to return the final TikTok URL format | ||
with patch("app.url_processing.follow_redirects", return_value="https://www.tiktok.com/video/7371578973689482539"): | ||
# Mock yt_dlp_download to simulate successful download | ||
with patch("app.url_processing.yt_dlp_download", return_value=expected_file_path) as mock_download: | ||
result = await process_url_request(test_url) | ||
|
||
# Assertions | ||
mock_download.assert_called_once_with(transformed_url) | ||
assert result == expected_file_path |