|
|
|
@@ -92,27 +92,35 @@ def test_get_image_paths_valid():
|
|
|
|
date = datetime(2025, 4, 10, 12, 30, 45)
|
|
|
|
date = datetime(2025, 4, 10, 12, 30, 45)
|
|
|
|
aeon_view_images = AeonViewImages(destination_base, url)
|
|
|
|
aeon_view_images = AeonViewImages(destination_base, url)
|
|
|
|
paths = aeon_view_images.get_image_paths(url, destination_base, date)
|
|
|
|
paths = aeon_view_images.get_image_paths(url, destination_base, date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a_p = destination_base / "2025-04" / "10" / "12-30-45.jpg"
|
|
|
|
|
|
|
|
|
|
|
|
assert paths["url"] == url
|
|
|
|
assert paths["url"] == url
|
|
|
|
assert paths["file"] == "12-30-45.jpg"
|
|
|
|
assert paths["file"] == "12-30-45.jpg"
|
|
|
|
assert paths["destinations"][
|
|
|
|
assert paths["destinations"]["file"] == a_p
|
|
|
|
"file"] == destination_base / "2025-04" / "10" / "12-30-45.jpg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_image_paths_invalid_url():
|
|
|
|
def test_get_image_paths_invalid_url():
|
|
|
|
with pytest.raises(SystemExit), mock.patch("aeonview.logging.error") as log:
|
|
|
|
with pytest.raises(SystemExit), mock.patch("aeonview.logging.error") as log:
|
|
|
|
aeon_view_images = AeonViewImages(default_test_path, "invalid-url")
|
|
|
|
aeon_view_images = AeonViewImages(default_test_path, "invalid-url")
|
|
|
|
aeon_view_images.get_image_paths("invalid-url", default_test_path,
|
|
|
|
aeon_view_images.get_image_paths(
|
|
|
|
datetime(2025, 4, 10))
|
|
|
|
"invalid-url",
|
|
|
|
|
|
|
|
default_test_path,
|
|
|
|
|
|
|
|
datetime(2025, 4, 10)
|
|
|
|
|
|
|
|
)
|
|
|
|
assert AeonViewMessages.INVALID_URL in log.call_args[0][0]
|
|
|
|
assert AeonViewMessages.INVALID_URL in log.call_args[0][0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_image_paths_invalid_date():
|
|
|
|
def test_get_image_paths_invalid_date():
|
|
|
|
with pytest.raises(SystemExit), mock.patch("aeonview.logging.error") as log:
|
|
|
|
with pytest.raises(SystemExit), mock.patch("aeonview.logging.error") as log:
|
|
|
|
aeon_view_images = AeonViewImages(default_test_path,
|
|
|
|
aeon_view_images = AeonViewImages(
|
|
|
|
f"{default_image_domain}.jpg")
|
|
|
|
|
|
|
|
aeon_view_images.get_image_paths(f"{default_image_domain}.jpg",
|
|
|
|
|
|
|
|
default_test_path,
|
|
|
|
default_test_path,
|
|
|
|
"invalid-date") # pyright: ignore [reportArgumentType]
|
|
|
|
f"{default_image_domain}.jpg"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
aeon_view_images.get_image_paths(
|
|
|
|
|
|
|
|
f"{default_image_domain}.jpg",
|
|
|
|
|
|
|
|
default_test_path,
|
|
|
|
|
|
|
|
"invalid-date" # pyright: ignore [reportArgumentType]
|
|
|
|
|
|
|
|
)
|
|
|
|
assert AeonViewMessages.INVALID_DATE in log.call_args[0][0]
|
|
|
|
assert AeonViewMessages.INVALID_DATE in log.call_args[0][0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -138,8 +146,11 @@ def test_download_image_success(mock_get):
|
|
|
|
with tempfile.NamedTemporaryFile(delete=True) as temp_file:
|
|
|
|
with tempfile.NamedTemporaryFile(delete=True) as temp_file:
|
|
|
|
destination = Path(temp_file.name)
|
|
|
|
destination = Path(temp_file.name)
|
|
|
|
avi.download_image(destination)
|
|
|
|
avi.download_image(destination)
|
|
|
|
mock_get.assert_called_once_with(f"{default_image_domain}.jpg",
|
|
|
|
mock_get.assert_called_once_with(
|
|
|
|
stream=True, timeout=10)
|
|
|
|
f"{default_image_domain}.jpg",
|
|
|
|
|
|
|
|
stream=True,
|
|
|
|
|
|
|
|
timeout=10
|
|
|
|
|
|
|
|
)
|
|
|
|
assert destination.exists()
|
|
|
|
assert destination.exists()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -161,8 +172,13 @@ def test_download_image_failure(mock_get):
|
|
|
|
@mock.patch("aeonview.AeonViewHelpers.mkdir_p")
|
|
|
|
@mock.patch("aeonview.AeonViewHelpers.mkdir_p")
|
|
|
|
@mock.patch("subprocess.run")
|
|
|
|
@mock.patch("subprocess.run")
|
|
|
|
def test_generate_daily_video(mock_subprocess_run, mock_mkdir_p):
|
|
|
|
def test_generate_daily_video(mock_subprocess_run, mock_mkdir_p):
|
|
|
|
args = argparse.Namespace(simulate=False, fps=10, day="01", month="04",
|
|
|
|
args = argparse.Namespace(
|
|
|
|
year="2025")
|
|
|
|
simulate=False,
|
|
|
|
|
|
|
|
fps=10,
|
|
|
|
|
|
|
|
day="01",
|
|
|
|
|
|
|
|
month="04",
|
|
|
|
|
|
|
|
year="2025"
|
|
|
|
|
|
|
|
)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
with mock.patch("aeonview.logging.info") as log:
|
|
|
|
with mock.patch("aeonview.logging.info") as log:
|
|
|
|
avv.generate_daily_video()
|
|
|
|
avv.generate_daily_video()
|
|
|
|
@@ -177,24 +193,39 @@ def test_generate_daily_video(mock_subprocess_run, mock_mkdir_p):
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch("aeonview.AeonViewHelpers.mkdir_p")
|
|
|
|
@mock.patch("aeonview.AeonViewHelpers.mkdir_p")
|
|
|
|
def test_generate_daily_video_simulate(mock_mkdir_p):
|
|
|
|
def test_generate_daily_video_simulate(mock_mkdir_p):
|
|
|
|
args = argparse.Namespace(simulate=True, fps=10, day="01", month="04",
|
|
|
|
args = argparse.Namespace(
|
|
|
|
year="2025")
|
|
|
|
simulate=True,
|
|
|
|
|
|
|
|
fps=10,
|
|
|
|
|
|
|
|
day="01",
|
|
|
|
|
|
|
|
month="04",
|
|
|
|
|
|
|
|
year="2025"
|
|
|
|
|
|
|
|
)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
avv.generate_daily_video()
|
|
|
|
avv.generate_daily_video()
|
|
|
|
mock_mkdir_p.assert_not_called()
|
|
|
|
mock_mkdir_p.assert_not_called()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_generate_monthly_video_not_implemented():
|
|
|
|
def test_generate_monthly_video_not_implemented():
|
|
|
|
args = argparse.Namespace(simulate=False, fps=10, day="01", month="04",
|
|
|
|
args = argparse.Namespace(
|
|
|
|
year="2025")
|
|
|
|
simulate=False,
|
|
|
|
|
|
|
|
fps=10,
|
|
|
|
|
|
|
|
day="01",
|
|
|
|
|
|
|
|
month="04",
|
|
|
|
|
|
|
|
year="2025"
|
|
|
|
|
|
|
|
)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
with pytest.raises(NotImplementedError):
|
|
|
|
with pytest.raises(NotImplementedError):
|
|
|
|
avv.generate_monthly_video(Path("/tmp"))
|
|
|
|
avv.generate_monthly_video(Path("/tmp"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_generate_yearly_video_not_implemented():
|
|
|
|
def test_generate_yearly_video_not_implemented():
|
|
|
|
args = argparse.Namespace(simulate=False, fps=10, day="01", month="04",
|
|
|
|
args = argparse.Namespace(
|
|
|
|
year="2025")
|
|
|
|
simulate=False,
|
|
|
|
|
|
|
|
fps=10,
|
|
|
|
|
|
|
|
day="01",
|
|
|
|
|
|
|
|
month="04",
|
|
|
|
|
|
|
|
year="2025"
|
|
|
|
|
|
|
|
)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
avv = AeonViewVideos(default_test_path, args)
|
|
|
|
with pytest.raises(NotImplementedError):
|
|
|
|
with pytest.raises(NotImplementedError):
|
|
|
|
avv.generate_yearly_video(Path("/tmp"))
|
|
|
|
avv.generate_yearly_video(Path("/tmp"))
|
|
|
|
@@ -234,8 +265,10 @@ def test_parse_arguments_fps():
|
|
|
|
assert args.fps == 30
|
|
|
|
assert args.fps == 30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch("sys.argv",
|
|
|
|
@mock.patch(
|
|
|
|
["aeonview.py", "--mode", "video", "--generate", "2023-10-01"])
|
|
|
|
"sys.argv",
|
|
|
|
|
|
|
|
["aeonview.py", "--mode", "video", "--generate", "2023-10-01"]
|
|
|
|
|
|
|
|
)
|
|
|
|
def test_parse_arguments_generate_date():
|
|
|
|
def test_parse_arguments_generate_date():
|
|
|
|
args, _ = AeonViewHelpers.parse_arguments()
|
|
|
|
args, _ = AeonViewHelpers.parse_arguments()
|
|
|
|
assert args.mode == "video"
|
|
|
|
assert args.mode == "video"
|
|
|
|
@@ -268,7 +301,10 @@ def test_image_simulation(mock_download_image, mock_mkdir_p):
|
|
|
|
args.simulate = True
|
|
|
|
args.simulate = True
|
|
|
|
args.date = "2025-04-10 12:30:45"
|
|
|
|
args.date = "2025-04-10 12:30:45"
|
|
|
|
avi = AeonViewImages(
|
|
|
|
avi = AeonViewImages(
|
|
|
|
default_test_path, f"{default_image_domain}.jpg", args)
|
|
|
|
default_test_path,
|
|
|
|
|
|
|
|
f"{default_image_domain}.jpg",
|
|
|
|
|
|
|
|
args
|
|
|
|
|
|
|
|
)
|
|
|
|
with mock.patch("aeonview.logging.info") as log:
|
|
|
|
with mock.patch("aeonview.logging.info") as log:
|
|
|
|
avi.get_current_image()
|
|
|
|
avi.get_current_image()
|
|
|
|
mock_mkdir_p.assert_not_called()
|
|
|
|
mock_mkdir_p.assert_not_called()
|
|
|
|
@@ -302,7 +338,8 @@ def test_setup_logger_verbose(mock_basic_config):
|
|
|
|
AeonViewHelpers.setup_logger(verbose=True)
|
|
|
|
AeonViewHelpers.setup_logger(verbose=True)
|
|
|
|
mock_basic_config.assert_called_once_with(
|
|
|
|
mock_basic_config.assert_called_once_with(
|
|
|
|
level=logging.DEBUG,
|
|
|
|
level=logging.DEBUG,
|
|
|
|
format="[%(levelname)s] %(message)s")
|
|
|
|
format="[%(levelname)s] %(message)s"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch("logging.basicConfig")
|
|
|
|
@mock.patch("logging.basicConfig")
|
|
|
|
@@ -310,4 +347,5 @@ def test_setup_logger_non_verbose(mock_basic_config):
|
|
|
|
AeonViewHelpers.setup_logger(verbose=False)
|
|
|
|
AeonViewHelpers.setup_logger(verbose=False)
|
|
|
|
mock_basic_config.assert_called_once_with(
|
|
|
|
mock_basic_config.assert_called_once_with(
|
|
|
|
level=logging.INFO,
|
|
|
|
level=logging.INFO,
|
|
|
|
format="[%(levelname)s] %(message)s")
|
|
|
|
format="[%(levelname)s] %(message)s"
|
|
|
|
|
|
|
|
)
|
|
|
|
|