Skip to content

Commit

Permalink
Add a test for the active_environment command
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch committed May 23, 2024
1 parent 077fd4d commit 3a9c9b2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
venv
*~
config/userconfig.yaml
checkout
Expand Down
50 changes: 50 additions & 0 deletions tests/test_active_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright (c) 2024 FZI Forschungszentrum Informatik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
import pytest

import os

from click.testing import CliRunner

import robot_folders.commands.active_environment
from robot_folders.helpers.directory_helpers import get_checkout_dir


def test_active_environment():
runner = CliRunner()

# First: Try to get the latest active env
env_file = os.path.join(get_checkout_dir(), ".cur_env")
with open(env_file, "w") as file_content:
file_content.write("testing_ws")
result = runner.invoke(robot_folders.commands.active_environment.cli)
assert (
result.output
== "No active environment. Last activated environment: testing_ws\n"
)
assert result.exit_code == 0

# Set an active env
os.environ["ROB_FOLDERS_ACTIVE_ENV"] = "testing_ws"
result = runner.invoke(robot_folders.commands.active_environment.cli)
assert result.output == "Active environment: testing_ws\n"
assert result.exit_code == 0

0 comments on commit 3a9c9b2

Please sign in to comment.