Skip to content

Commit

Permalink
Remove publish date check
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Apr 17, 2024
1 parent 77cd0fb commit 1f46e9e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
21 changes: 0 additions & 21 deletions geotribu_cli/content/header_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
import shutil
import uuid
from datetime import datetime
from typing import Any

import requests
import yaml
Expand All @@ -13,7 +11,6 @@
from geotribu_cli.__about__ import __executable_name__, __version__
from geotribu_cli.constants import GeotribuDefaults
from geotribu_cli.content.json_feed import JsonFeedClient
from geotribu_cli.utils.dates_manipulation import is_more_recent

logger = logging.getLogger(__name__)
defaults_settings = GeotribuDefaults()
Expand Down Expand Up @@ -83,15 +80,6 @@ def parser_header_check(
# ################################


def check_publish_date(date: Any) -> bool:
if isinstance(date, str):
publish_date = datetime.strptime(date.split(" ")[0], "%Y-%m-%d").date()
else:
publish_date = date
# TODO: check if date is another type and raise error
return is_more_recent(datetime.now().date(), publish_date)


def check_image_ratio(image_url: str, min_ratio: float, max_ratio: float) -> bool:
r = requests.get(
image_url,
Expand Down Expand Up @@ -162,15 +150,6 @@ def run(args: argparse.Namespace) -> None:
yaml_meta = yaml.safe_load(front_matter)
logger.debug(f"YAML metadata loaded : {yaml_meta}")

# check that datetime is in the future
if not check_publish_date(yaml_meta["date"]):
msg = "La date de publication n'est pas dans le turfu !"
logger.error(msg)
if args.raise_exceptions:
raise ValueError(msg)
else:
logger.info("Date de publication ok")

# check that image ratio is okayyy
if "image" in yaml_meta:
if not check_image_ratio(
Expand Down
7 changes: 0 additions & 7 deletions tests/test_yaml_header_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from geotribu_cli.content.header_check import (
check_existing_tags,
check_mandatory_keys,
check_publish_date,
check_tags_order,
)

Expand All @@ -23,12 +22,6 @@ def setUp(self):
_, front_matter, _ = future_content.split("---", 2)
self.future_yaml_meta = yaml.safe_load(front_matter)

def test_past_publish_date(self):
self.assertFalse(check_publish_date(self.past_yaml_meta["date"]))

def test_future_publish_date(self):
self.assertTrue(check_publish_date(self.future_yaml_meta["date"]))

@patch("geotribu_cli.content.header_check.get_existing_tags")
def test_past_tags_existence(self, get_existing_tags_mock):
get_existing_tags_mock.return_value = ["QGIS", "OSM"]
Expand Down

0 comments on commit 1f46e9e

Please sign in to comment.