Source

PythonDojo / Xmas2012 / test_twelve_days.py

Full commit
#!/usr/bin/env python
# encoding: utf-8
"""
test_twelve_days.py

Created by Coding Dojo on 2012-12-16.
"""

from nose.tools import assert_equal

import twelve_days

def test_song():
        assert_equal(twelve_days.song(),
                 '\n'.join([
                            "The first day of Christmas",
                            "My true love gave to me",
                            "A partridge in a pear tree",
                            "",
                            "The second day of Christmas",
                            "My true love gave to me",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The third day of Christmas",
                            "My true love gave to me",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The fourth day of Christmas",
                            "My true love gave to me",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The fifth day of Christmas",
                            "My true love gave to me",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The sixth day of Christmas",
                            "My true love gave to me",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The seventh day of Christmas",
                            "My true love gave to me",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The eighth day of Christmas",
                            "My true love gave to me",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The ninth day of Christmas",
                            "My true love gave to me",
                            "Nine drummers drumming,",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The tenth day of Christmas",
                            "My true love gave to me",
                            "Ten ladies dancing,",
                            "Nine drummers drumming,",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The eleventh day of Christmas",
                            "My true love gave to me",
                            "Eleven pipers piping,",
                            "Ten ladies dancing,",
                            "Nine drummers drumming,",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            "",
                            "The twelfth day of Christmas",
                            "My true love gave to me",
                            "Twelve lords a-leaping,",
                            "Eleven pipers piping,",
                            "Ten ladies dancing,",
                            "Nine drummers drumming,",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree",
                            ]))


def test_twelfth_verse():
        assert_equal(twelve_days.verse(12),
                 '\n'.join(["The twelfth day of Christmas",
                            "My true love gave to me",
                            "Twelve lords a-leaping,",
                            "Eleven pipers piping,",
                            "Ten ladies dancing,",
                            "Nine drummers drumming,",
                            "Eight maids a-milking,",
                            "Seven swans a-swimming,",
                            "Six geese a-laying,",
                            "Five gold rings,",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree"]))

def test_fourth_verse():
        assert_equal(twelve_days.verse(4),
                 '\n'.join(["The fourth day of Christmas",
                            "My true love gave to me",
                            "Four colly birds,",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree"]))


def test_third_verse():
        assert_equal(twelve_days.verse(3),
                 '\n'.join(["The third day of Christmas",
                            "My true love gave to me",
                            "Three French hens,",
                            "Two turtle doves,",
                            "And a partridge in a pear tree"]))

def test_first_verse():
    assert_equal(twelve_days.verse(1),
                 '\n'.join(["The first day of Christmas",
                            "My true love gave to me",
                            "A partridge in a pear tree"]))

def test_second_verse():
    assert_equal(twelve_days.verse(2),
                 '\n'.join(["The second day of Christmas",
                            "My true love gave to me",
                            "Two turtle doves,",
                            "And a partridge in a pear tree"]))