Skip to content

Commit

Permalink
refactor test_clean.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Feb 22, 2024
1 parent 1ccc838 commit b644a31
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/code_commands/test_clean.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,54 @@
"""
Test for the "apio clean" command
"""

# -- apio clean entry point
from apio.commands.clean import cli as cmd_clean

# -- apio init entry point
from apio.commands.init import cli as cmd_init


def test_clean(clirunner, configenv):
"""Test: apio clean
when no apio.ini file is given
No additional parameters are given
"""

with clirunner.isolated_filesystem():

# -- Config the environment (conftest.configenv())
configenv()

# -- Execute "apio clean"
result = clirunner.invoke(cmd_clean)

# -- It is an error. Exit code should not be 0
assert result.exit_code != 0
assert "Info: No apio.ini file" in result.output
assert "Error: insufficient arguments: missing board" in result.output

# -- Execute "apio clean --board alhambra-ii"
result = clirunner.invoke(cmd_clean, ["--board", "alhambra-ii"])
assert result.exit_code != 0


def test_clean_init(clirunner, configenv):
"""Test: apio clean
when there is an apio.ini file
"""

with clirunner.isolated_filesystem():

# -- Config the environment (conftest.configenv())
configenv()

# apio init --board icezum
result = clirunner.invoke(cmd_init, ["--board", "alhambra-ii"])
assert result.exit_code == 0
assert "Creating apio.ini file ..." in result.output
assert "has been successfully created!" in result.output

# --- Execute "apio clean"
result = clirunner.invoke(cmd_clean)
assert result.exit_code != 0

0 comments on commit b644a31

Please sign in to comment.