Add CI tests using the standard test interface

This commit is contained in:
Serhii Turivnyi 2018-05-07 17:38:28 +03:00
parent e6977d878e
commit 7b9ad57ccd
2 changed files with 11 additions and 18 deletions

View File

@ -5,47 +5,39 @@ import subprocess
def call_command(command_to_call): def call_command(command_to_call):
call = subprocess.check_call(command_to_call, shell=True) result = subprocess.check_output(command_to_call, shell=True)
output = subprocess.check_output(command_to_call, shell=True) return result[:-1].decode("utf-8")
return call, output[:-1]
class TestBC(unittest.TestCase): class TestBC(unittest.TestCase):
def test_divide(self): def test_divide(self):
result = call_command("echo '6.5 / 2.7' | bc") result = call_command("echo '6.5 / 2.7' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '2')
self.assertEqual( result[1], '2')
def test_sum(self): def test_sum(self):
result = call_command("echo '2 + 5' | bc") result = call_command("echo '2 + 5' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '7')
self.assertEqual( result[1], '7')
def test_difference(self): def test_difference(self):
result = call_command("echo '10 - 4' | bc") result = call_command("echo '10 - 4' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '6')
self.assertEqual( result[1], '6')
def test_multiplying(self): def test_multiplying(self):
result = call_command("echo '3 * 8' | bc") result = call_command("echo '3 * 8' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '24')
self.assertEqual( result[1], '24')
def test_scale(self): def test_scale(self):
result = call_command("echo 'scale = 2; 2 / 3' | bc") result = call_command("echo 'scale = 2; 2 / 3' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '.66')
self.assertEqual( result[1], '.66')
def test_remainder(self): def test_remainder(self):
result = call_command("echo '6 % 4' | bc") result = call_command("echo '6 % 4' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '2')
self.assertEqual( result[1], '2')
def test_exponent(self): def test_exponent(self):
result = call_command("echo '10^2' | bc") result = call_command("echo '10^2' | bc")
self.assertEqual( result[0], 0) self.assertEqual( result, '100')
self.assertEqual( result[1], '100')
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,4 +1,5 @@
--- ---
# This first play always runs on the local staging system
- hosts: localhost - hosts: localhost
roles: roles:
- role: standard-test-basic - role: standard-test-basic
@ -11,4 +12,4 @@
dir: sanity dir: sanity
run: python3 runtests.py -v run: python3 runtests.py -v
required_packages: required_packages:
- bc - bc # Required to run initscript