mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-12 05:28:34 +03:00
Add pre-commit with GiHub Action (#56)
* Update pyproject.toml * add pre-commit * Create .pre-commit-config.yaml * Comment out ruff * Update .pre-commit-config.yaml * General formatting * Create format-and-fail.yml * Update ci.yml * Add pre-commit to dev dependencies * Update pyproject.toml
This commit is contained in:
@@ -3,4 +3,4 @@ def test_generate_uuid():
|
||||
|
||||
assert generate_uuid() != generate_uuid()
|
||||
assert len(generate_uuid()) == 36
|
||||
assert generate_uuid().count("-") == 4
|
||||
assert generate_uuid().count("-") == 4
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from app.shared.db import models
|
||||
from app.shared.db import worker_crud, models
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
from app.shared.db import models, worker_crud
|
||||
from app.tests.web.db.test_crud import test_data
|
||||
|
||||
|
||||
def test_update_sheet_last_url_archived_at(db_session):
|
||||
|
||||
# Create test sheet
|
||||
@@ -19,7 +18,7 @@ def test_update_sheet_last_url_archived_at(db_session):
|
||||
db_session.refresh(test_sheet)
|
||||
assert isinstance(test_sheet.last_url_archived_at, datetime)
|
||||
assert test_sheet.last_url_archived_at > before
|
||||
|
||||
|
||||
# Test non-existent sheet
|
||||
assert worker_crud.update_sheet_last_url_archived_at(db_session, "non-existent-sheet") is False
|
||||
|
||||
@@ -73,8 +72,8 @@ def test_create_tag(db_session):
|
||||
|
||||
|
||||
def test_create_task(db_session):
|
||||
from app.shared.db import worker_crud
|
||||
from app.shared import schemas
|
||||
from app.shared.db import worker_crud
|
||||
|
||||
task = schemas.ArchiveCreate(
|
||||
id="archive-id-456-101",
|
||||
@@ -114,4 +113,4 @@ def test_create_task(db_session):
|
||||
assert nt.group_id == "spaceship"
|
||||
assert len(nt.tags) == 0
|
||||
assert len(nt.urls) == 0
|
||||
assert nt.created_at is not None
|
||||
assert nt.created_at is not None
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from app.shared.business_logic import get_store_archive_until, get_store_archive_until_or_never
|
||||
|
||||
from app.shared.business_logic import (
|
||||
get_store_archive_until,
|
||||
get_store_archive_until_or_never,
|
||||
)
|
||||
|
||||
|
||||
class Test_get_store_archive_until:
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_fnv1a_hash_mod():
|
||||
|
||||
# Test different modulos
|
||||
hash1 = fnv1a_hash_mod("test", 5)
|
||||
hash2 = fnv1a_hash_mod("test", 10)
|
||||
hash2 = fnv1a_hash_mod("test", 10)
|
||||
assert 0 <= hash1 < 5
|
||||
assert 0 <= hash2 < 10
|
||||
|
||||
@@ -28,4 +28,4 @@ def test_fnv1a_hash_mod():
|
||||
assert 0 <= fnv1a_hash_mod("测试", 10) < 10
|
||||
|
||||
# Test modulo = 1 edge case
|
||||
assert fnv1a_hash_mod("test", 1) == 0
|
||||
assert fnv1a_hash_mod("test", 1) == 0
|
||||
|
||||
Reference in New Issue
Block a user