Skip to content

Commit

Permalink
Add tests for file cli
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-ifak committed Aug 25, 2024
1 parent 7667b9d commit 6bf7d31
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from unittest import TestCase
import subprocess
import os

script_dir = os.path.dirname(os.path.realpath(__file__))


class CheckFileCli(TestCase):

json_file = os.path.join(script_dir, 'fixtures', 'aasx', 'valid', 'json', 'aasx', 'the_aas.json')
xml_file = os.path.join(script_dir, 'fixtures', 'aasx', 'valid', 'xml', 'aasx', 'the_aas.xml')

def invoke(self, args: list):
result = subprocess.check_output(["python", "-m", "aas_test_engines", "check_file"] + args)
return result.decode()

def test_no_arguments(self):
with self.assertRaises(subprocess.CalledProcessError):
self.invoke([])

def test_json(self):
self.invoke([self.json_file, '--format', 'json'])

def test_xml(self):
self.invoke([self.xml_file, '--format', 'xml'])

def test_html_output(self):
result = self.invoke([self.json_file, '--format', 'json', '--output', 'html'])
self.assertTrue(result.startswith('<!DOCTYPE html>'))

def test_invalid_file(self):
with self.assertRaises(subprocess.CalledProcessError):
self.invoke([self.json_file, '--format', 'xml'])

0 comments on commit 6bf7d31

Please sign in to comment.