# Path: ratechecker/tests/helpers.py
# def write_sample_dataset(filename):
#     content = get_sample_dataset_zipfile().read()
#     with open(filename, "wb") as f:
#         f.write(content)


import os
import shutil
import tempfile
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase
from mock import patch
from ratechecker.tests.helpers import write_sample_dataset

    def touch_file(self, f):
        with open(f, "a"):
            os.utime(f, None)

    def test_run_command_no_arguments(self):
        with self.assertRaises(CommandError):
            call_command("load_daily_data", verbosity=0)

    def test_run_command_invalid_filename(self):
        with self.assertRaises(CommandError):
            call_command("load_daily_data", "invalid-path", verbosity=0)

    @patch("ratechecker.loader.Loader.load")
    def test_run_command_invalid_scenario_file(self, _):
        archive_filename = os.path.join(self.tempdir, "archive.zip")
        write_sample_dataset(archive_filename)

        with self.assertRaises(CommandError):
            call_command(
                "load_daily_data",
                archive_filename,
                "--validation-scenario-file",
                "invalid.jsonl",
                verbosity=0,
            )

    @patch("ratechecker.loader.Loader.load")
    def test_run_command_calls_load(self, load):
        archive_filename = os.path.join(self.tempdir, "archive.zip")

# Path: ratechecker/tests/helpers.py
# def write_sample_dataset(filename):
#     content = get_sample_dataset_zipfile().read()
#     with open(filename, "wb") as f:
#         f.write(content)


# Path: ratechecker/tests/management/commands/test_load_daily_data.py
import os
import shutil
import tempfile
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase
from mock import patch
from ratechecker.tests.helpers import write_sample_dataset


    def touch_file(self, f):
        with open(f, "a"):
            os.utime(f, None)

    def test_run_command_no_arguments(self):
        with self.assertRaises(CommandError):
            call_command("load_daily_data", verbosity=0)

    def test_run_command_invalid_filename(self):
        with self.assertRaises(CommandError):
            call_command("load_daily_data", "invalid-path", verbosity=0)

    @patch("ratechecker.loader.Loader.load")
    def test_run_command_invalid_scenario_file(self, _):
        archive_filename = os.path.join(self.tempdir, "archive.zip")
        write_sample_dataset(archive_filename)

        with self.assertRaises(CommandError):
            call_command(
                "load_daily_data",
                archive_filename,
                "--validation-scenario-file",
                "invalid.jsonl",
                verbosity=0,
            )

    @patch("ratechecker.loader.Loader.load")
    def test_run_command_calls_load(self, load):
        archive_filename = os.path.join(self.tempdir, "archive.zip")

        write_sample_dataset(archive_filename)