kopia lustrzana https://github.com/bellingcat/auto-archiver
Fix merge conflicts.
rodzic
846474a4e2
commit
72f48f0147
|
@ -1,22 +1,24 @@
|
|||
name: Ruff Formatting & Linting
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
ruff:
|
||||
name: Run Ruff Checks
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run Ruff (Lint & Format Check)
|
||||
uses: astral-sh/ruff-action@v1
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
args: "check . --output-format=concise"
|
||||
python-version: "3.11"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install ruff
|
||||
|
||||
- name: Run Ruff Format Check
|
||||
uses: astral-sh/ruff-action@v1
|
||||
with:
|
||||
args: "format --check ."
|
||||
- name: Run Ruff
|
||||
run: ruff check --output-format=github . && ruff format --check
|
|
@ -396,7 +396,7 @@ class GenericExtractor(Extractor):
|
|||
item.set("replaced_url", url)
|
||||
|
||||
ydl_options = {
|
||||
"outtmpl": os.path.join(self.tmp_dir, f"%(id)s.%(ext)s"),
|
||||
"outtmpl": os.path.join(self.tmp_dir, "%(id)s.%(ext)s"),
|
||||
"quiet": False,
|
||||
"noplaylist": not self.allow_playlist,
|
||||
"writesubtitles": self.subtitles,
|
||||
|
|
|
@ -38,7 +38,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
|
|||
mock_get.return_value.status_code = 200
|
||||
mock_get.return_value.json.side_effect = ValueError
|
||||
with caplog.at_level("DEBUG"):
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False
|
||||
mock_get.assert_called_once()
|
||||
mock_get.return_value.json.assert_called_once()
|
||||
# first message is just the 'Skipping using ytdlp to download files for TikTok' message
|
||||
|
@ -49,7 +49,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
|
|||
|
||||
mock_get.return_value.json.side_effect = Exception
|
||||
with caplog.at_level("ERROR"):
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False
|
||||
mock_get.assert_called()
|
||||
assert mock_get.call_count == 2
|
||||
assert mock_get.return_value.json.call_count == 2
|
||||
|
@ -69,7 +69,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
|
|||
mock_get.return_value.status_code = 200
|
||||
mock_get.return_value.json.return_value = response
|
||||
with caplog.at_level("DEBUG"):
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False
|
||||
assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False
|
||||
mock_get.assert_called_once()
|
||||
mock_get.return_value.json.assert_called_once()
|
||||
assert "failed to get a valid response from tikwm.com" in caplog.text
|
||||
|
@ -82,10 +82,9 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
|
|||
({"data": {"play": "url"}}, True),
|
||||
],
|
||||
)
|
||||
def test_correct_extraction(self, mock_get, make_item, response, has_vid):
|
||||
def test_correct_extraction(self, mock_get, make_item, response, has_vid, mocker):
|
||||
mock_get.return_value.status_code = 200
|
||||
mock_get.return_value.json.return_value = {"msg": "success", **response}
|
||||
|
||||
result = self.extractor.download(make_item(self.VALID_EXAMPLE_URL))
|
||||
if not has_vid:
|
||||
assert result is False
|
||||
|
@ -95,13 +94,8 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
|
|||
mock_get.assert_called()
|
||||
assert mock_get.call_count == 1 + int(has_vid)
|
||||
mock_get.return_value.json.assert_called_once()
|
||||
if not has_vid:
|
||||
mock_logger.error.assert_called_once()
|
||||
assert mock_logger.error.call_args[0][0].startswith("no valid video URL found")
|
||||
else:
|
||||
mock_logger.error.assert_not_called()
|
||||
|
||||
def test_correct_extraction(self, mock_get, make_item):
|
||||
def test_correct_data_extracted(self, mock_get, make_item):
|
||||
mock_get.return_value.status_code = 200
|
||||
mock_get.return_value.json.return_value = {
|
||||
"msg": "success",
|
||||
|
|
Ładowanie…
Reference in New Issue