# Path: tests/testapp/models.py
# class Author(Model):
#     name = CharField(max_length=32, db_index=True)
#     tutor = ForeignKey("self", on_delete=CASCADE, null=True, related_name="tutees")
#     bio = TextField()
#     birthday = DateTimeField(null=True)
#     deathday = DateTimeField(null=True)
# 
# class AuthorMultiIndex(Model):
#     class Meta:
#         index_together = ("name", "country")
# 
#     name = CharField(max_length=32, db_index=True)
#     country = CharField(max_length=32)


from unittest import SkipTest, mock
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.test import SimpleTestCase, TestCase
from django_mysql.utils import (
    WeightedAverageRate,
    connection_is_mariadb,
    format_duration,
    index_name,
)
from tests.testapp.models import Author, AuthorMultiIndex
    from django_mysql.utils import _is_mariadb_cache
import django
import pytest
        assert format_duration(1) == "1s"
        assert format_duration(30) == "30s"
        assert format_duration(59) == "59s"

    def test_minutes(self):
        assert format_duration(60) == "1m0s"
        assert format_duration(61) == "1m1s"
        assert format_duration(120) == "2m0s"
        assert format_duration(3599) == "59m59s"

    def test_hours(self):
        assert format_duration(3600) == "1h0m0s"
        assert format_duration(3601) == "1h0m1s"


class IndexNameTests(TestCase):

    databases = ["default", "other"]

    def test_requires_field_names(self):
        with pytest.raises(ValueError) as excinfo:
            index_name(Author)
        assert "At least one field name required" in str(excinfo.value)

    def test_requires_real_field_names(self):
        with pytest.raises(ValueError) as excinfo:
            index_name(Author, "nonexistent")
        assert "Fields do not exist: nonexistent" in str(excinfo.value)

    def test_primary_key(self):

# Path: tests/testapp/models.py
# class Author(Model):
#     name = CharField(max_length=32, db_index=True)
#     tutor = ForeignKey("self", on_delete=CASCADE, null=True, related_name="tutees")
#     bio = TextField()
#     birthday = DateTimeField(null=True)
#     deathday = DateTimeField(null=True)
# 
# class AuthorMultiIndex(Model):
#     class Meta:
#         index_together = ("name", "country")
# 
#     name = CharField(max_length=32, db_index=True)
#     country = CharField(max_length=32)


# Path: tests/testapp/test_utils.py
from unittest import SkipTest, mock
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.test import SimpleTestCase, TestCase
from django_mysql.utils import (
    WeightedAverageRate,
    connection_is_mariadb,
    format_duration,
    index_name,
)
from tests.testapp.models import Author, AuthorMultiIndex
    from django_mysql.utils import _is_mariadb_cache
import django
import pytest

        assert format_duration(1) == "1s"
        assert format_duration(30) == "30s"
        assert format_duration(59) == "59s"

    def test_minutes(self):
        assert format_duration(60) == "1m0s"
        assert format_duration(61) == "1m1s"
        assert format_duration(120) == "2m0s"
        assert format_duration(3599) == "59m59s"

    def test_hours(self):
        assert format_duration(3600) == "1h0m0s"
        assert format_duration(3601) == "1h0m1s"


class IndexNameTests(TestCase):

    databases = ["default", "other"]

    def test_requires_field_names(self):
        with pytest.raises(ValueError) as excinfo:
            index_name(Author)
        assert "At least one field name required" in str(excinfo.value)

    def test_requires_real_field_names(self):
        with pytest.raises(ValueError) as excinfo:
            index_name(Author, "nonexistent")
        assert "Fields do not exist: nonexistent" in str(excinfo.value)

    def test_primary_key(self):

        assert index_name(Author, "id") == "PRIMARY"