Skip to content

Commit

Permalink
Fix import errors from #86 (#87)
Browse files Browse the repository at this point in the history
* Add tests to reproduce import errors #86

* Add missing imports for #86 after adding tests to reproduce

* Create temporary files so that the deployment tests need less mocking

* Improve variable name to fix spelling

* Add spelling expectation for tempfile
  • Loading branch information
rmelick-muon committed Jul 21, 2022
1 parent 65126bf commit fc1c02b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ tcpserver
td
telem
tempdir
tempfile
testcase
TESTLIST
textarea
Expand Down
1 change: 1 addition & 0 deletions src/fprime_gds/executables/run_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import platform
import webbrowser
from pathlib import Path

import fprime_gds.executables.cli
import fprime_gds.executables.utils
Expand Down
1 change: 1 addition & 0 deletions src/fprime_gds/executables/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import atexit
import signal
import subprocess
import sys
import time
from pathlib import Path
from fprime.fbuild.settings import (
Expand Down
35 changes: 35 additions & 0 deletions test/fprime_gds/executables/test_run_deployment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import platform
import tempfile
import unittest
from pathlib import Path

from unittest import mock

from fprime_gds.executables import run_deployment


class TestRunDeployment(unittest.TestCase):

def test_as_in_installation_instructions(self):
# Same as the "Testing F´ GDS Installation Via Running HTML GUI" from
# https://nasa.github.io/fprime/INSTALL.html
# fprime-gds -g html -r <path to fprime checkout>/Ref/build-artifacts
with tempfile.TemporaryDirectory() as temporary_directory:
self.create_fake_deployment_structure(temporary_directory)
with mock.patch("sys.argv", ["main", "-g", "html", "-r", temporary_directory]):
run_deployment.get_settings()

def create_fake_deployment_structure(self, temporary_directory):
system_dir = Path(temporary_directory) / platform.system()

bin_dir = system_dir / "bin"
bin_dir.mkdir(parents=True)
bin_file = bin_dir / "Test"
with bin_file.open(mode="wb") as fake_app:
fake_app.write("fake app".encode("utf-8"))

dictionary_dir = system_dir / "dict"
dictionary_dir.mkdir(parents=True)
dictionary_file = dictionary_dir / "TestTopologyAppDictionary.xml"
with dictionary_file.open(mode="w") as fake_dictionary:
fake_dictionary.write("<test></test>")
17 changes: 17 additions & 0 deletions test/fprime_gds/executables/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import unittest
from pathlib import Path

from fprime_gds.executables import utils


class TestFormatString(unittest.TestCase):

def test_find_app_with_no_bin_dir_exits(self):
path_with_no_bin = Path("")
with self.assertRaises(SystemExit):
utils.find_app(path_with_no_bin)

def test_find_dict_with_no_dict_dir_exits(self):
path_with_no_dict = Path("")
with self.assertRaises(SystemExit):
utils.find_app(path_with_no_dict)

0 comments on commit fc1c02b

Please sign in to comment.