# Path: ish_parser/CloudCoverage.py
# class CloudCoverage(Observation):
#   '''okta is a unit of measurement used to 
#   describe the amount of cloud cover at any given location such 
#   as a weather station. Sky conditions are estimated in 
#   terms of how many eighths of the sky are covered in cloud, 
#   ranging from 0 oktas (completely clear sky) through to 
#   8 oktas (completely overcast).
#   '''
#   OKTA = 1
#   MISSING = ['99', 99]
# 
#   def __str__(self):
#     if self._obs_value in self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
#   def __repr__(self):
#     return self.__str__()
# 
#   def __eq__(self, value2):
#     if self._obs_value == value2:
#       return True
#     else:
#       return False
# 
# Path: ish_parser/Minutes.py
# class Minutes(Observation):
#   ''' represents (obviously) minutes '''
#   MISSING = 9999
#   MINUTES_IN_HOUR = 60.00
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return int(self._obs_value)
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == other_value:
#       return True
#     else:
#       return False
# 
#   def get_hours(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return self._obs_value / self.MINUTES_IN_HOUR
# 
# Path: ish_parser/Irradiance.py
# class Irradiance(Observation):
#   ''' Global horizontal irradiance measured using a pyranometer. Unit is watts per square meter
#    (W/m2) in whole values. Waveband ranges from 0.4 - 2.3 micrometers.'''
#   MISSING = 9999
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return self._obs_value
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == other_value:
#       return True
#     else:
#       return False


import unittest
from ish_parser import CloudCoverage, Minutes, Irradiance
from ish_parser.Components import *

class SkyCoverComponentTest(unittest.TestCase):

  def test_string(self):
    sample_string = '005+999999999'
    sky = SkyCoverComponent()
    sky.loads(sample_string)
    self.assertEqual(sky.sky_cover['coverage'], 
      CloudCoverage('00', CloudCoverage.OKTA, '5'))

class SolarIrradianceComponentTest(unittest.TestCase):
  
  def test_string(self):
    sample_string = '006010140690989029013102999999'
    sol = SolarIrradianceComponent()
    sol.loads(sample_string)
    self.assertEqual(sol.solar_irradiance['time_period'], Minutes(60))
    self.assertEqual(sol.solar_irradiance['global_irradiance'], Irradiance('1014'))
    self.assertEqual(sol.solar_irradiance['irradiance_data_flag'],
      'Value estimated; passes all pertinent SERI_QC tests')
    self.assertEqual(sol.solar_irradiance['direct_beam_irradiance'], Irradiance('0989'))
    self.assertEqual(sol.solar_irradiance['uvb_global_irradiance'], Irradiance('9999'))

class SkyConditionObservationComponentTest(unittest.TestCase):

  def test_string(self):
    sample_string = '08991999999999999999999'
    sky = SkyConditionObservationComponent()
    sky.loads(sample_string)
    self.assertEqual(sky.sky_condition_observation['total_coverage'],

# Path: ish_parser/CloudCoverage.py
# class CloudCoverage(Observation):
#   '''okta is a unit of measurement used to 
#   describe the amount of cloud cover at any given location such 
#   as a weather station. Sky conditions are estimated in 
#   terms of how many eighths of the sky are covered in cloud, 
#   ranging from 0 oktas (completely clear sky) through to 
#   8 oktas (completely overcast).
#   '''
#   OKTA = 1
#   MISSING = ['99', 99]
# 
#   def __str__(self):
#     if self._obs_value in self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
#   def __repr__(self):
#     return self.__str__()
# 
#   def __eq__(self, value2):
#     if self._obs_value == value2:
#       return True
#     else:
#       return False
# 
# Path: ish_parser/Minutes.py
# class Minutes(Observation):
#   ''' represents (obviously) minutes '''
#   MISSING = 9999
#   MINUTES_IN_HOUR = 60.00
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return int(self._obs_value)
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == other_value:
#       return True
#     else:
#       return False
# 
#   def get_hours(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return self._obs_value / self.MINUTES_IN_HOUR
# 
# Path: ish_parser/Irradiance.py
# class Irradiance(Observation):
#   ''' Global horizontal irradiance measured using a pyranometer. Unit is watts per square meter
#    (W/m2) in whole values. Waveband ranges from 0.4 - 2.3 micrometers.'''
#   MISSING = 9999
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return self._obs_value
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == other_value:
#       return True
#     else:
#       return False


# Path: tests/ComponentTest.py
import unittest
from ish_parser import CloudCoverage, Minutes, Irradiance
from ish_parser.Components import *


class SkyCoverComponentTest(unittest.TestCase):

  def test_string(self):
    sample_string = '005+999999999'
    sky = SkyCoverComponent()
    sky.loads(sample_string)
    self.assertEqual(sky.sky_cover['coverage'], 
      CloudCoverage('00', CloudCoverage.OKTA, '5'))

class SolarIrradianceComponentTest(unittest.TestCase):
  
  def test_string(self):
    sample_string = '006010140690989029013102999999'
    sol = SolarIrradianceComponent()
    sol.loads(sample_string)
    self.assertEqual(sol.solar_irradiance['time_period'], Minutes(60))
    self.assertEqual(sol.solar_irradiance['global_irradiance'], Irradiance('1014'))
    self.assertEqual(sol.solar_irradiance['irradiance_data_flag'],
      'Value estimated; passes all pertinent SERI_QC tests')
    self.assertEqual(sol.solar_irradiance['direct_beam_irradiance'], Irradiance('0989'))
    self.assertEqual(sol.solar_irradiance['uvb_global_irradiance'], Irradiance('9999'))

class SkyConditionObservationComponentTest(unittest.TestCase):

  def test_string(self):
    sample_string = '08991999999999999999999'
    sky = SkyConditionObservationComponent()
    sky.loads(sample_string)
    self.assertEqual(sky.sky_condition_observation['total_coverage'],

      CloudCoverage('08', CloudCoverage.OKTA, '1'))