Coverage for tests/unit_tests/commands/test_apio_upload.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-07 05:08 +0000

1# This file is part of the Apio project 

2# (C) 2016-present FPGAwars 

3# Project authors: 

4# * Jesús Arroyo (Jesus89) (2016-2019) 

5# * Juan Gonzalez (obijuan) (2019-2024) 

6# * The Apio Team (2024-present) 

7# License: GPLv2 

8 

9"""Test for the "apio upload" command.""" 

10 

11from tests.conftest import ApioRunner 

12from apio.commands.apio import apio_top_cli as apio 

13 

14 

15def test_upload_without_apio_ini(apio_runner: ApioRunner): 

16 """Test: apio upload 

17 when no apio.ini file is given 

18 No additional parameters are given 

19 """ 

20 

21 with apio_runner.in_sandbox() as sb: 

22 

23 # -- Execute "apio upload" 

24 result = sb.invoke_apio_cmd(apio, ["upload"]) 

25 

26 # -- Check the result 

27 assert result.exit_code == 1, result.output 

28 assert "Error: Missing project file apio.ini" in result.output 

29 

30 

31def test_upload_with_env_arg_error(apio_runner: ApioRunner): 

32 """Tests the command with an invalid --env value. This error message 

33 confirms that the --env arg was propagated to the apio.ini loading 

34 logic.""" 

35 

36 with apio_runner.in_sandbox() as sb: 

37 

38 # -- Run "apio upload --env no-such-env" 

39 sb.write_apio_ini({"[env:default]": {"top-module": "main"}}) 

40 result = sb.invoke_apio_cmd(apio, ["upload", "--env", "no-such-env"]) 

41 assert result.exit_code == 1, result.output 

42 assert ( 

43 "Error: Env 'no-such-env' not found in apio.ini" in result.output 

44 )