26 lines
653 B
Python
26 lines
653 B
Python
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()
|