Skip to content

Commit

Permalink
#86dt89kf4 - Refactor BoaCliTest on cli_tests to use BoaConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirella de Medeiros committed Apr 17, 2024
1 parent aa848c1 commit 6972205
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
11 changes: 5 additions & 6 deletions boa3_test/tests/cli_tests/cli_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from boa3_test.tests.boa_test import (BoaTest, # needs to be the first import to avoid circular imports
_COMPILER_LOCK as LOCK,
_LOGGING_LOCK as LOG_LOCK
)

__all__ = [
'BoaCliTest',
]
Expand All @@ -12,10 +7,14 @@
from contextlib import redirect_stdout, redirect_stderr

from boa3.cli import main
from boa3_test.tests import boatestcase
from boa3_test.tests.boatestcase import (_COMPILER_LOCK as LOCK,
_LOGGING_LOCK as LOG_LOCK
)
from boa3_test.tests.cli_tests import utils


class BoaCliTest(BoaTest, abc.ABC):
class BoaCliTest(boatestcase.BoaTestCase, abc.ABC):
default_folder = 'test_cli'

EXIT_CODE_SUCCESS = 0
Expand Down
3 changes: 1 addition & 2 deletions boa3_test/tests/cli_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from boa3_test.tests.cli_tests.cli_test import BoaCliTest # needs to be the first import to avoid circular imports

from boa3.internal import constants
from boa3_test.tests.cli_tests.cli_test import BoaCliTest
from boa3_test.tests.cli_tests.utils import neo3_boa_cli


Expand Down
24 changes: 10 additions & 14 deletions boa3_test/tests/cli_tests/test_compile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os.path

from boa3_test.tests.cli_tests.cli_test import BoaCliTest # needs to be the first import to avoid circular imports

from boa3.internal import constants
from boa3.internal.neo3.vm import VMState
from boa3_test.tests.cli_tests.cli_test import BoaCliTest
from boa3_test.tests.cli_tests.utils import neo3_boa_cli, get_path_from_boa3_test
from boa3_test.tests.test_drive.testrunner.boa_test_runner import BoaTestRunner


class TestCliCompile(BoaCliTest):
Expand Down Expand Up @@ -111,10 +108,13 @@ def test_cli_compile_new_output_path(self):
@neo3_boa_cli('compile', get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py'),
'-e', 'env_changed',
'-o', get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env_cli.nef', get_unique=True))
def test_cli_compile_env(self):
async def test_cli_compile_env(self):
contract_path = get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py')
output_name = 'Env_cli.nef'

nef_path, _ = self.get_deploy_file_paths(
get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py'),
output_name='Env_cli.nef',
contract_path,
output_name=output_name,
compile_if_found=False
)
nef_generated = nef_path.split(constants.PATH_SEPARATOR)[-1]
Expand All @@ -127,15 +127,11 @@ def test_cli_compile_env(self):
self.assertTrue(f'Wrote {nef_generated} to ' in logs.output[-1],
msg=f'Something went wrong when compiling {nef_generated}')

runner = BoaTestRunner(runner_id=self.method_name())
await self.set_up_contract(contract_path, output_name=output_name)

runner.deploy_contract(nef_path)
invoke = runner.call_contract(nef_path, 'main')
expected_result = 'env_changed'
runner.execute()
self.assertEqual(VMState.HALT, runner.vm_state, msg=runner.error)

self.assertEqual(invoke.result, expected_result)
result, _ = await self.call('main', return_type=str)
self.assertEqual(expected_result, result)

@neo3_boa_cli('compile', 'wrong_file')
def test_cli_compile_wrong_file(self):
Expand Down

0 comments on commit 6972205

Please sign in to comment.