# Path: openaq/utils.py
# def mass_to_mix(value, param, unit='ppb', **kwargs):
#     """Convert units from ug/m3 to ppb or ppm. The conversion assumes an ambient
#     pressure of 1 atmosphere and ambient temperature of 25 degC.
# 
#     :param value: the concentration in ug/m3
#     :param param: the parameter to convert {'co', 'no', 'no2', 'so2', 'o3'}
#     :param unit: the desired output unit {'ppb', 'ppm'}
# 
#     :type value: float
#     :type param: string
#     :type unit: string
# 
#     :returns: value
# 
#     :Example:
# 
#     >>> import openaq
#     >>> conc_ugm3 = 100
#     >>> conc_ppb = openaq.utils.mass_to_mix(conc_ugm3, param='co', unit='ppb')
#     >>> conc_ppb
#     114.5
# 
#     """
#     lookup = {
#         'co': 1.145,
#         'no': 1.25,
#         'no2': 1.88,
#         'so2': 2.62,
#         'o3': 2.0
#     }
# 
#     param = param.lower()
# 
#     if param not in lookup.keys():
#         return value
# 
#     value = value / lookup[param]
# 
#     if unit.lower() == 'ppm':
#         value *= 1e-3
# 
#     return value


import unittest
import openaq
import pandas as pd
from openaq.utils import mass_to_mix


class SetupTestCase(unittest.TestCase):
    def setUp(self):
        self.api = openaq.OpenAQ()

    def tearDown(self):
        pass

    def test_mass_to_mix(self):
        mix = mass_to_mix(value=1.145, param='co', unit='ppb')

        self.assertEqual(mix, 1.)

        # Test ppm

# Path: openaq/utils.py
# def mass_to_mix(value, param, unit='ppb', **kwargs):
#     """Convert units from ug/m3 to ppb or ppm. The conversion assumes an ambient
#     pressure of 1 atmosphere and ambient temperature of 25 degC.
# 
#     :param value: the concentration in ug/m3
#     :param param: the parameter to convert {'co', 'no', 'no2', 'so2', 'o3'}
#     :param unit: the desired output unit {'ppb', 'ppm'}
# 
#     :type value: float
#     :type param: string
#     :type unit: string
# 
#     :returns: value
# 
#     :Example:
# 
#     >>> import openaq
#     >>> conc_ugm3 = 100
#     >>> conc_ppb = openaq.utils.mass_to_mix(conc_ugm3, param='co', unit='ppb')
#     >>> conc_ppb
#     114.5
# 
#     """
#     lookup = {
#         'co': 1.145,
#         'no': 1.25,
#         'no2': 1.88,
#         'so2': 2.62,
#         'o3': 2.0
#     }
# 
#     param = param.lower()
# 
#     if param not in lookup.keys():
#         return value
# 
#     value = value / lookup[param]
# 
#     if unit.lower() == 'ppm':
#         value *= 1e-3
# 
#     return value


# Path: tests/test_utils.py
import unittest
import openaq
import pandas as pd
from openaq.utils import mass_to_mix



class SetupTestCase(unittest.TestCase):
    def setUp(self):
        self.api = openaq.OpenAQ()

    def tearDown(self):
        pass

    def test_mass_to_mix(self):
        mix = mass_to_mix(value=1.145, param='co', unit='ppb')

        self.assertEqual(mix, 1.)

        # Test ppm

        mix = mass_to_mix(value=1145, param='co', unit='ppm')