add tests
This commit is contained in:
25
tests/test.py
Normal file
25
tests/test.py
Normal file
@@ -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()
|
||||||
Reference in New Issue
Block a user