Example #1
0
class GetAddressCommandTestCase(TestCase):
    """Test case for CLI get_address command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_run_positive(self, *mocks):
        """Test for CLI get_address positive result."""
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "get-address", FETCHAI],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
Example #2
0
class GenerateWealthCommandTestCase(TestCase):
    """Test case for CLI generate_wealth command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_run_positive(self, *mocks):
        """Test for CLI generate_wealth positive result."""
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "generate-wealth", "--sync", FETCHAI],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
Example #3
0
class AddContractCommandTestCase(TestCase):
    """Test that the command 'aea add contract' works as expected."""
    def setUp(self):
        """Set the test up."""
        self.runner = CliRunner()

    @mock.patch("aea.cli.add._add_item")
    def test_add_contract_positive(self, *mocks):
        """Test add contract command positive result."""
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "add", "contract", "author/name:0.1.0"],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
        result = self.runner.invoke(
            cli,
            [
                *CLI_LOG_OPTION, "add", "--local", "contract",
                "author/name:0.1.0"
            ],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
Example #4
0
class AddKeyCommandTestCase(TestCase):
    """Test case for CLI add_key command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_run_positive(self, *mocks):
        """Test for CLI add_key positive result."""
        filepath = "setup.py"  # some existing filepath to pass CLI argument check
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "add-key", FETCHAI, filepath],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
Example #5
0
class RemoveContractCommandTestCase(TestCase):
    """Test that the command 'aea remove contract' works as expected."""
    def setUp(self):
        """Set the test up."""
        self.runner = CliRunner()

    @mock.patch("aea.cli.remove._remove_item")
    def test_remove_contract_positive(self, *mocks):
        """Test remove contract command positive result."""
        result = self.runner.invoke(
            cli,
            [
                *CLI_LOG_OPTION,
                "--skip-consistency-check",
                "remove",
                "contract",
                "author/name:0.1.0",
            ],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
Example #6
0
class LoginTestCase(TestCase):
    """Test case for CLI login command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_login_positive(self, _update_cli_config_mock,
                            registry_login_mock):
        """Test for CLI login positive result."""
        username, password = ("Username", "Password")
        result = self.runner.invoke(
            cli,
            [
                *CLI_LOG_OPTION, "login", username,
                "--password={}".format(password)
            ],
            standalone_mode=False,
        )
        expected_output = ("Signing in as Username...\n"
                           "Successfully signed in: Username.\n")
        self.assertEqual(result.output, expected_output)
        registry_login_mock.assert_called_once_with(username, password)
        _update_cli_config_mock.assert_called_once_with(
            {"auth_token": "token"})