<gh_stars>1-10
"""
    Title: test_bal_esti.py
    Author: <NAME>, <EMAIL>
    CreationDate: 2015-07-02
    Description: Unit testing module for bal_esti function in calculate_bal.py
"""

import sys
import os.path
import unittest
from inspect import getfile, currentframe


class TestBalEsti(unittest.TestCase):

    def test_bal_esti(self):

        cmd_folder = os.path.realpath(
                     os.path.abspath(os.path.split(
                     getfile(currentframe()))[0]))

        parent = os.path.abspath(os.path.join(cmd_folder, os.pardir))

        if parent not in sys.path:
            sys.path.insert(0, parent)

        from calculate_bal import bal_esti

        veg_list = [-99, 1, 2, 3, 4, 5, 6, 7]
        dist_list = [12.5, 37.5, 62.5, 87.5]
        slope_list = [-99, -1, 1, 2, 3, 4, 5, 6]
        fdi_list = [80, 50]

        result_expect = [-99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 19,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 19, 12.5, -99,
                         -99, -99, -99, -99, -99, 100, 19, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5,
                         12.5, 12.5, 19, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 19, 12.5, -99, -99, -99, -99, -99, -99, 100, 19,
                         12.5, 12.5, 100, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 29, 12.5, -99, -99, -99, -99, -99,
                         -99, 100, 29, 12.5, 12.5, 100, 19, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, -99, -99,
                         -99, -99, -99, -99, 100, 40, 19, 12.5, 100, 29, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 29, 12.5, -99,
                         -99, -99, -99, -99, -99, 100, 100, 29, 12.5, 100, 29,
                         19, 12.5, 40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5,
                         40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 40, 12.5,
                         -99, -99, -99, -99, -99, -99, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, 40, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 19, 12.5, 12.5, 12.5, 19, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, -99, -99, -99, -99, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 19, 12.5, 12.5, 12.5, 19, 12.5,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, -99, -99, -99, -99,
                         100, 19, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 19, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, -99,
                         -99, -99, -99, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, -99, -99, -99, -99, 100, 29, 12.5, 12.5,
                         100, 19, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 100, 19,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, -99, -99, -99, -99, 100,
                         29, 19, 12.5, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 100, 19, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, -99, -99, -99,
                         -99, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200]

        result = []

        for fdi in fdi_list:
            for slope in slope_list:
                for veg in veg_list:
                    for dist in dist_list:
                        bal = bal_esti(veg, dist, slope, fdi)
                        result.append(bal)

        self.assertEqual(result, result_expect)


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

"""
    Title: test_bal_esti.py
    Author: <NAME>, <EMAIL>
    CreationDate: 2015-07-02
    Description: Unit testing module for bal_esti function in calculate_bal.py
"""

import sys
import os.path
import unittest
from inspect import getfile, currentframe


class TestBalEsti(unittest.TestCase):

    def test_bal_esti(self):

        cmd_folder = os.path.realpath(
                     os.path.abspath(os.path.split(
                     getfile(currentframe()))[0]))

        parent = os.path.abspath(os.path.join(cmd_folder, os.pardir))

        if parent not in sys.path:
            sys.path.insert(0, parent)

        from calculate_bal import bal_esti

        veg_list = [-99, 1, 2, 3, 4, 5, 6, 7]
        dist_list = [12.5, 37.5, 62.5, 87.5]
        slope_list = [-99, -1, 1, 2, 3, 4, 5, 6]
        fdi_list = [80, 50]

        result_expect = [-99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 19,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 19, 12.5, -99,
                         -99, -99, -99, -99, -99, 100, 19, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5,
                         12.5, 12.5, 19, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 19, 12.5, -99, -99, -99, -99, -99, -99, 100, 19,
                         12.5, 12.5, 100, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 29, 12.5, -99, -99, -99, -99, -99,
                         -99, 100, 29, 12.5, 12.5, 100, 19, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, -99, -99,
                         -99, -99, -99, -99, 100, 40, 19, 12.5, 100, 29, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 29, 12.5, -99,
                         -99, -99, -99, -99, -99, 100, 100, 29, 12.5, 100, 29,
                         19, 12.5, 40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5,
                         40, 12.5, 12.5, 12.5, 100, 19, 12.5, 12.5, 40, 12.5,
                         -99, -99, -99, -99, -99, -99, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
                         -99, -99, -99, -99, 40, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 19, 12.5, 12.5, 12.5, 19, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, -99, -99, -99, -99, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 19, 12.5, 12.5, 12.5, 19, 12.5,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, -99, -99, -99, -99,
                         100, 19, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, 40, 12.5, 12.5, 12.5, 29, 12.5, 12.5,
                         12.5, 19, 12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, -99,
                         -99, -99, -99, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 29,
                         12.5, 12.5, 12.5, 29, 12.5, 12.5, 12.5, 29, 12.5,
                         12.5, 12.5, -99, -99, -99, -99, 100, 29, 12.5, 12.5,
                         100, 19, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 100, 19,
                         12.5, 12.5, 29, 12.5, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 40, 12.5, 12.5, 12.5, -99, -99, -99, -99, 100,
                         29, 19, 12.5, 100, 19, 12.5, 12.5, 40, 12.5, 12.5,
                         12.5, 100, 19, 12.5, 12.5, 40, 12.5, 12.5, 12.5, 40,
                         12.5, 12.5, 12.5, 40, 12.5, 12.5, 12.5, -99, -99, -99,
                         -99, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
                         200, 200, 200, 200, 200, 200, 200]

        result = []

        for fdi in fdi_list:
            for slope in slope_list:
                for veg in veg_list:
                    for dist in dist_list:
                        bal = bal_esti(veg, dist, slope, fdi)
                        result.append(bal)

        self.assertEqual(result, result_expect)


if __name__ == "__main__":
    unittest.main()
Title: test_bal_esti.py     Author: <NAME>, <EMAIL>     CreationDate: 2015-07-02     Description: Unit testing module for bal_esti function in calculate_bal.py