# -*- coding: utf-8 -*-
import numpy as np
import ibei
from astropy import units
import unittest

temp_sun = 5762.
temp_earth = 288.
bandgap = 1.15

input_params = {"temp_sun": temp_sun,
                "temp_earth": temp_earth,
                "bandgap": bandgap,
                "voltage": 0.5,}

class Issues(unittest.TestCase):
    """
    Tests output types of the calculator methods.
    """

    # def test_issue_1_devos_efficiency(self):
    #     """
    #     Unit system needs to be specified for astropy.constants.e to work.
    #     """
    #     try:
    #         ibei.devos_efficiency(bandgap, temp_sun, temp_earth, 1.09)
    #     except:
    #         self.fail("Unit system not initialized.")

class SBSolarcellCalculatorsReturnUnits(unittest.TestCase):
    """
    Tests units of the calculator methods returned values.
    """
    def setUp(self):
        """
        Initialize SBSolarcell object from input_params
        """
        self.solarcell = ibei.SQSolarcell(input_params)

    def test_calc_blackbody_radiant_power_density(self):
        """
        calc_blackbody_radiant_power_density should return value with unit of W m^-2.
        """
        tested_unit = self.solarcell.calc_blackbody_radiant_power_density().unit
        target_unit = units.Unit("W/m2")
        self.assertEqual(tested_unit, target_unit)

    def test_calc_power_density(self):
        """
        calc_power_density should return value with unit of W m^-2.
        """
        tested_unit = self.solarcell.calc_power_density().unit
        target_unit = units.Unit("W/m2")
        self.assertEqual(tested_unit, target_unit)


class SBSolarcellCalculatorsReturnType(unittest.TestCase):
    """
    Tests type of the calculator methods returned values.
    """
    def setUp(self):
        """
        Initialize SBSolarcell object from input_params
        """
        self.solarcell = ibei.SQSolarcell(input_params)

    def test_calc_efficiency(self):
        """
        calc_power_density should return value with unit of W m^-2.
        """
        self.assertIsInstance(self.solarcell.calc_efficiency(), float)


if __name__ == "__main__":
    pass

@@ -202,21 +202,22 @@
   %22temp_
-earth
+planet
 %22: temp_
@@ -2122,16 +2122,606 @@
 loat)%0A%0A%0A
+class DeVosSolarcellCalculatorsReturnUnits(unittest.TestCase):%0A    %22%22%22%0A    Tests units of the calculator methods returned values.%0A    %22%22%22%0A    def setUp(self):%0A        %22%22%22%0A        Initialize DeVosSolarcell object from input_params%0A        %22%22%22%0A        self.solarcell = ibei.DeVosSolarcell(input_params)%0A%0A    def test_calc_power_density(self):%0A        %22%22%22%0A        calc_power_density should return value with unit of W m%5E-2.%0A        %22%22%22%0A        tested_unit = self.solarcell.calc_power_density().unit%0A        target_unit = units.Unit(%22W/m2%22)%0A        self.assertEqual(tested_unit, target_unit)%0A%0A%0A
 if __nam

Test ret. unit of DeVosSolarcell.calc_power_density