"""
------------------------------------------------------------------------------
--                                                                          --
--                                 LAB 07                                   --
--                                                                          --
--                       L A B 0 7 _ T E S T S . P Y                        --
--                                                                          --
------------------------------------------------------------------------------
-- <Your Name Here>                                                         --
--                                                                          --
-- CISC106 010 Summer 2012                                                  --
--                                                                          --
------------------------------------------------------------------------------
-- This file contains unit tests for the functions in module lab07.         --
--                                                                          --
------------------------------------------------------------------------------
"""

from lab07 import *
import unittest

class TestLabSeven(unittest.TestCase):
    def test_create_ff7save(self):
        str1 = 'Level : 25;Name : Cloud;HP : 976/976;MP : 85/85;Characters : Cloud, Aerith & Cid;Gil : 54916;Location : "Costa Del Sol"'
        str2 = 'Level : 57;Name : Cid;HP : 5198/5274;MP : 497/497;Characters : Cid, Cloud & Yuffie;Gil : 1238699;Location : "Midgar Area"'
        str3 = 'Level : 10;Name : Aerith;HP : 105/110;MP : 32/42;Characters : Aerith, Cloud;Gil : 1686;Location : "Wall Market"'

        ff7save1 = {
            'level' : 25,
            'name' : 'Cloud',
            'current_hp' : 976,
            'max_hp' : 976,
            'current_mp' : 85,
            'max_mp' : 85,
            'characters' : ['Cloud', 'Aerith', 'Cid'],
            'gil' : 54916,
            'location' : '"Costa Del Sol"'
        }

        ff7save2 = {
            'level' : 57,
            'name' : 'Cid',
            'current_hp' : 5198,
            'max_hp' : 5274,
            'current_mp' : 497,
            'max_mp' : 497,
            'characters' : ['Cid', 'Cloud', 'Yuffie'],
            'gil' : 1238699,
            'location' : '"Midgar Area"'
        }

        ff7save3 = {
            'level' : 10,
            'name' : 'Aerith',
            'current_hp' : 105,
            'max_hp' : 110,
            'current_mp' : 32,
            'max_mp' : 42,
            'characters' : ['Aerith', 'Cloud', 'No one'],
            'gil' : 1686,
            'location' : '"Wall Market"'
        }

        self.assertEqual(create_ff7save(str1), ff7save1)
        self.assertEqual(create_ff7save(str2), ff7save2)
        self.assertEqual(create_ff7save(str3), ff7save3)

    def test_ff7save_to_csv(self):
        str1 = 'Level : 25;Name : Cloud;HP : 976/976;MP : 85/85;Characters : Cloud, Aerith & Cid;Gil : 54916;Location : "Costa Del Sol"'
        str2 = 'Level : 57;Name : Cid;HP : 5198/5274;MP : 497/497;Characters : Cid, Cloud & Yuffie;Gil : 1238699;Location : "Midgar Area"'
        str3 = 'Level : 10;Name : Aerith;HP : 105/110;MP : 32/42;Characters : Aerith, Cloud;Gil : 1686;Location : "Wall Market"'

        self.assertEqual(to_csv_string(create_ff7save(str1)), 'Cloud,25,976,976,85,85,Cloud,Aerith,Cid,54916,"Costa Del Sol"')
        self.assertEqual(to_csv_string(create_ff7save(str2)), 'Cid,57,5198,5274,497,497,Cid,Cloud,Yuffie,1238699,"Midgar Area"')
        self.assertEqual(to_csv_string(create_ff7save(str3)), 'Aerith,10,105,110,32,42,Aerith,Cloud,No one,1686,"Wall Market"')

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