Skip to content

Commit

Permalink
Add dom0 tests for sd-export-config
Browse files Browse the repository at this point in the history
  • Loading branch information
emkll committed Aug 2, 2019
1 parent ecbe347 commit 8b59dcf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_sd_export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json
import re
import unittest

from base import SD_VM_Local_Test
Expand All @@ -21,6 +23,23 @@ def test_sd_export_package_installed(self):
self.assertTrue(self._package_is_installed("cryptsetup"))
self.assertTrue(self._package_is_installed("printer-driver-brlaser"))

def test_sd_export_config_present(self):
with open("config.json") as c:
config = json.load(c)

# Extract values from config.json
match = re.match(r'sys-usb:(\d)-(\d)', config['usb']['device'])
pci_bus_id_value = match.group(1)
usb_device_value = match.group(2)

wanted_lines = [
"{",
" \"pci_bus_id\": \"{}\",".format(pci_bus_id_value),
" \"usb_device\": \"{}\"".format(usb_device_value),
"}",
]
for line in wanted_lines:
self.assertFileHasLine("/etc/sd-export-config.json", line)

def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Export_Tests)
Expand Down

0 comments on commit 8b59dcf

Please sign in to comment.