-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isd_generate.py): Added the ability to provide a kernel file.
- Loading branch information
Showing
2 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
"""This module has unit tests for the isd_generate functions.""" | ||
|
||
# This is free and unencumbered software released into the public domain. | ||
# | ||
# The authors of ale do not claim copyright on the contents of this file. | ||
# For more details about the LICENSE terms and the AUTHORS, you will | ||
# find files of those names at the top level of this repository. | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
import unittest | ||
from unittest.mock import call, patch | ||
|
||
import ale.isd_generate as isdg | ||
|
||
|
||
class TestFile(unittest.TestCase): | ||
|
||
@patch("ale.isd_generate.Path.write_text") | ||
def test_file_to_isd(self, m_path_wt): | ||
|
||
json_text = "some json text" | ||
cube_str = "dummy.cub" | ||
|
||
with patch("ale.loads", return_value=json_text) as m_loads: | ||
cube_str = "dummy.cub" | ||
isdg.file_to_isd(cube_str) | ||
self.assertEqual( | ||
m_loads.call_args_list, [call(cube_str)] | ||
) | ||
self.assertEqual( | ||
m_path_wt.call_args_list, [call(json_text)] | ||
) | ||
|
||
m_path_wt.reset_mock() | ||
with patch("ale.loads", return_value=json_text) as m_loads: | ||
out_str = "dummy.json" | ||
kernel_val = "list of kernels" | ||
isdg.file_to_isd(cube_str, out=out_str, kernels=kernel_val) | ||
self.assertEqual( | ||
m_loads.call_args_list, | ||
[call(cube_str, props={'kernels': kernel_val})] | ||
) | ||
self.assertEqual( | ||
m_path_wt.call_args_list, [call(json_text)] | ||
) |