#!/usr/bin/env python
""" """

# Script information for the file.
__author__ = "Philippe T. Pinard"
__email__ = "philippe.pinard@gmail.com"
__version__ = "0.1"
__copyright__ = "Copyright (c) 2011 Philippe T. Pinard"
__license__ = "GPL v3"

# Standard library modules.
import unittest
import logging

# Third party modules.

# Local modules.
from stratagemtools.layer import Layer

# Globals and constants variables.

class TestLayer(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)

        elements = {29: 0.5, 30: 0.4}
        self.l1 = Layer(elements, thickness=5.0)
        self.l2 = Layer(elements, mass_thickness=3.668)
        self.l3 = Layer(elements)

    def tearDown(self):
        unittest.TestCase.tearDown(self)

    def testskeleton(self):
        self.assertEqual(2, len(list(self.l1.iter_elements())))
        self.assertAlmostEqual(5.0, self.l1.thickness, 3)
        self.assertAlmostEqual(3.668, self.l1.mass_thickness, 3)
        self.assertAlmostEqual(7.336, self.l1.density, 3)
        self.assertTrue(self.l1.is_thickness_known())

        self.assertEqual(2, len(list(self.l2.iter_elements())))
        self.assertAlmostEqual(5.0, self.l2.thickness, 3)
        self.assertAlmostEqual(3.668, self.l2.mass_thickness, 3)
        self.assertAlmostEqual(7.336, self.l2.density, 3)
        self.assertTrue(self.l2.is_thickness_known())

        self.assertEqual(2, len(list(self.l3.iter_elements())))
        self.assertAlmostEqual(-1.0, self.l3.thickness, 3)
        self.assertAlmostEqual(-1.0, self.l3.mass_thickness, 3)
        self.assertAlmostEqual(7.336, self.l3.density, 3)
        self.assertFalse(self.l3.is_thickness_known())

if __name__ == '__main__': #pragma: no cover
    logging.getLogger().setLevel(logging.DEBUG)
    unittest.main()

@@ -515,24 +515,27 @@
         
-elements
+composition
  = %7B29: 
@@ -548,16 +548,55 @@
 0: 0.4%7D%0A
+        density_kg_m3 = 7.336 * 1000.0%0A
         
@@ -611,24 +611,27 @@
 = Layer(
-elements
+composition
 , thickn
@@ -637,12 +637,46 @@
 ness
+_m
 =5.0
+e-4, density_kg_m3=density_kg_m3
 )%0A  
@@ -697,24 +697,27 @@
 = Layer(
-elements
+composition
 , mass_t
@@ -728,48 +728,115 @@
 ness
-=3.668)%0A        self.l3 = Layer(elements
+_kg_m2=3.668, density_kg_m3=density_kg_m3)%0A        self.l3 = Layer(composition, density_kg_m3=density_kg_m3
 )%0A%0A 
@@ -973,31 +973,27 @@
 self.l1.
-iter_elements()
+composition
 )))%0A    
@@ -1014,32 +1014,35 @@
 tAlmostEqual(5.0
+e-4
 , self.l1.thickn
@@ -1036,32 +1036,34 @@
 elf.l1.thickness
+_m
 , 3)%0A        sel
@@ -1103,32 +1103,38 @@
 1.mass_thickness
+_kg_m2
 , 3)%0A        sel
@@ -1146,33 +1146,32 @@
 ertAlmostEqual(7
-.
 336, self.l1.den
@@ -1166,32 +1166,38 @@
  self.l1.density
+_kg_m3
 , 3)%0A        sel
@@ -1285,31 +1285,27 @@
 self.l2.
-iter_elements()
+composition
 )))%0A    
@@ -1334,16 +1334,19 @@
 qual(5.0
+e-4
 , self.l
@@ -1348,32 +1348,34 @@
 elf.l2.thickness
+_m
 , 3)%0A        sel
@@ -1415,32 +1415,38 @@
 2.mass_thickness
+_kg_m2
 , 3)%0A        sel
@@ -1458,33 +1458,32 @@
 ertAlmostEqual(7
-.
 336, self.l2.den
@@ -1478,32 +1478,38 @@
  self.l2.density
+_kg_m3
 , 3)%0A        sel
@@ -1601,23 +1601,19 @@
 .l3.
-iter_elements()
+composition
 )))%0A
@@ -1631,34 +1631,23 @@
 f.assert
-AlmostEqual(-1.0, 
+IsNone(
 self.l3.
@@ -1647,35 +1647,34 @@
 elf.l3.thickness
-, 3
+_m
 )%0A        self.a
@@ -1682,26 +1682,15 @@
 sert
-AlmostEqual(-1.0, 
+IsNone(
 self
@@ -1707,19 +1707,22 @@
 hickness
-, 3
+_kg_m2
 )%0A      
@@ -1747,17 +1747,16 @@
 tEqual(7
-.
 336, sel
@@ -1767,16 +1767,22 @@
 .density
+_kg_m3
 , 3)%0A   

Fix tests.