-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 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
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
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,35 @@ | ||
import unittest | ||
import unittest.mock | ||
from pathlib import Path | ||
import shutil | ||
import os | ||
import subprocess | ||
|
||
from click.testing import CliRunner | ||
|
||
from manati.utils import find_project_data, task | ||
|
||
|
||
class TestUtils(unittest.TestCase): | ||
|
||
@unittest.mock.patch('manati.utils.shell') | ||
@unittest.mock.patch('manati.utils.os.environ.get') | ||
def test_find_project_data_author_from_env(self, mock_env, mock_shell): | ||
mock_shell.return_value = subprocess.run('blabla1234', shell=True) | ||
|
||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
mock_env.return_value = 'test_user' | ||
info = find_project_data() | ||
assert info.get('author') == 'test_user' | ||
|
||
@unittest.mock.patch('manati.utils.click.secho') | ||
def test_task(self, mock_secho): | ||
|
||
@task('Before', 'After') | ||
def func(): | ||
raise Exception | ||
|
||
with self.assertRaises(Exception): | ||
func() | ||
mock_secho.assert_called_with('ERROR') |