diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..e6de80d --- /dev/null +++ b/tests/test.py @@ -0,0 +1,25 @@ +import unittest +import materials +import json +import shlex +import subprocess + + +class TestGet(unittest.TestCase): + + def test_property(self): + self.assertEqual(materials.get_value(json.loads('{"rho": 2.5}'), "rho"), 2.5, "Should be 6") + + def test_property_nested(self): + self.assertEqual(materials.get_value(json.loads('{"node": {"rho": 2.5}}'), "node/rho"), 2.5, "Should be 6") + +class TestCLI(unittest.TestCase): + + def test_property(self): + cmd = shlex.split("materials get Al -r") + output = subprocess.check_output(cmd).decode('utf-8').strip() + self.assertEqual(output, '2.6989 g/cm³') + + +if __name__ == '__main__': + unittest.main()