import unittest

from food_chain import (
    recite,
)

# Tests adapted from `problem-specifications//canonical-data.json`


class FoodChainTest(unittest.TestCase):
    def test_fly(self):
        self.assertEqual(
            recite(1, 1),
            [
                "I know an old lady who swallowed a fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_spider(self):
        self.assertEqual(
            recite(2, 2),
            [
                "I know an old lady who swallowed a spider.",
                "It wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_bird(self):
        self.assertEqual(
            recite(3, 3),
            [
                "I know an old lady who swallowed a bird.",
                "How absurd to swallow a bird!",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_cat(self):
        self.assertEqual(
            recite(4, 4),
            [
                "I know an old lady who swallowed a cat.",
                "Imagine that, to swallow a cat!",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_dog(self):
        self.assertEqual(
            recite(5, 5),
            [
                "I know an old lady who swallowed a dog.",
                "What a hog, to swallow a dog!",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_goat(self):
        self.assertEqual(
            recite(6, 6),
            [
                "I know an old lady who swallowed a goat.",
                "Just opened her throat and swallowed a goat!",
                "She swallowed the goat to catch the dog.",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_cow(self):
        self.assertEqual(
            recite(7, 7),
            [
                "I know an old lady who swallowed a cow.",
                "I don't know how she swallowed a cow!",
                "She swallowed the cow to catch the goat.",
                "She swallowed the goat to catch the dog.",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_horse(self):
        self.assertEqual(
            recite(8, 8),
            ["I know an old lady who swallowed a horse.", "She's dead, of course!"],
        )

    def test_multiple_verses(self):
        self.assertEqual(
            recite(1, 3),
            [
                "I know an old lady who swallowed a fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a spider.",
                "It wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a bird.",
                "How absurd to swallow a bird!",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
            ],
        )

    def test_full_song(self):
        self.assertEqual(
            recite(1, 8),
            [
                "I know an old lady who swallowed a fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a spider.",
                "It wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a bird.",
                "How absurd to swallow a bird!",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a cat.",
                "Imagine that, to swallow a cat!",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a dog.",
                "What a hog, to swallow a dog!",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a goat.",
                "Just opened her throat and swallowed a goat!",
                "She swallowed the goat to catch the dog.",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a cow.",
                "I don't know how she swallowed a cow!",
                "She swallowed the cow to catch the goat.",
                "She swallowed the goat to catch the dog.",
                "She swallowed the dog to catch the cat.",
                "She swallowed the cat to catch the bird.",
                "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
                "She swallowed the spider to catch the fly.",
                "I don't know why she swallowed the fly. Perhaps she'll die.",
                "",
                "I know an old lady who swallowed a horse.",
                "She's dead, of course!",
            ],
        )


if __name__ == "__main__":
    unittest.main()
