Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions iotlabcli/tests/auth_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@

import sys
import unittest
from unittest.mock import patch

import iotlabcli.parser.auth as auth_parser
from iotlabcli import auth

from .c23 import patch

# pylint: disable=missing-docstring,too-many-public-methods


Expand Down Expand Up @@ -84,7 +83,7 @@ def test_main(self, getpass_m, store_m, ssh_key_m, ssh_keys_m):

# List ssh key with -u/-p options
ssh_key_m.reset_mock()
ssh_keys_m.call_count = 0
ssh_keys_m.reset_mock()
api.check_credential.return_value = True
store_m.return_value = "Written"
auth_parser.main(["-u", "super_user", "-p", "password", "--list-ssh-keys"])
Expand Down
5 changes: 2 additions & 3 deletions iotlabcli/tests/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@

import os
import unittest
from unittest.mock import mock_open, patch

from iotlabcli import auth

from .c23 import mock_open, patch

TEST_RC_FILE = "test_iotlabrc_file"


Expand Down Expand Up @@ -133,7 +132,7 @@ def test_add_ssh_key(self, m_api_class):
test_keys["sshkeys"].append(TEST_SSHKEYS)
api.set_ssh_keys.assert_called_with(test_keys)

api.get_ssh_keys.call_count = 0
api.get_ssh_keys.reset_mock()
# Cannot add a key that is already stored (here it's in test_keys)
self.assertRaises(ValueError, auth.add_ssh_key, TEST_SSH_IDENTITY_FILE)
api.get_ssh_keys.assert_called_once()
Expand Down
47 changes: 0 additions & 47 deletions iotlabcli/tests/c23.py

This file was deleted.

7 changes: 4 additions & 3 deletions iotlabcli/tests/common_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
import argparse
import sys
import unittest
from io import StringIO
from unittest.mock import Mock, patch
from urllib.error import HTTPError

from iotlabcli.parser import common
from iotlabcli.parser.common import print_result
from iotlabcli.tests.my_mock import api_mock, api_mock_stop

from .c23 import HTTPError, Mock, StringIO, patch

BUILTIN = "builtins" if sys.version_info[0] == 3 else "__builtin__"
BUILTIN = "builtins"


class TestCommonParser(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/experiment_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

import argparse
import unittest
from io import StringIO
from unittest.mock import patch

import iotlabcli.parser.experiment as experiment_parser
from iotlabcli import experiment
from iotlabcli.tests import resource_file
from iotlabcli.tests.my_mock import MainMock

from .c23 import StringIO, patch


class TestMainInfoParser(MainMock):
"""Test experiment.parser."""
Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/experiment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

import json
import unittest
from unittest import mock
from unittest.mock import mock_open, patch

from iotlabcli import experiment, helpers, rest, tests
from iotlabcli.tests.my_mock import API_RET, CommandMock, RequestRet

from .c23 import mock, mock_open, patch

SCRIPTS = {
"script.sh": (b'#! /bin/sh\necho "script.sh"\n'),
"script_2.sh": (b'#! /bin/sh\necho "script_2.sh"\n'),
Expand Down
3 changes: 1 addition & 2 deletions iotlabcli/tests/helpers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
import sys
import unittest
import warnings
from unittest.mock import patch

import pytest

from iotlabcli import helpers
from iotlabcli.tests import my_mock

from .c23 import patch


class TestHelpers(unittest.TestCase):
"""Test the iotlabcli.helpers module"""
Expand Down
12 changes: 2 additions & 10 deletions iotlabcli/tests/main_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
import argparse
import subprocess
import sys
from unittest.mock import patch

import pytest

import iotlabcli.parser.main as main_parser

from .c23 import patch, version_info


@pytest.mark.parametrize(
"entry", ["auth", "experiment", "node", "profile", "robot", "status"]
Expand Down Expand Up @@ -70,14 +69,7 @@ def test_help(argv, exc):
except ImportError:
iotlabsshcli = None

try:
import iotlabaggregator

if version_info[0] != 2:
# pylint: disable=invalid-name
iotlabaggregator = None # noqa
except (ImportError, TypeError):
iotlabaggregator = None
iotlabaggregator = None # pylint: disable=invalid-name

try:
import oml_plot_tools
Expand Down
3 changes: 1 addition & 2 deletions iotlabcli/tests/my_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
import json
import sys
import unittest
from unittest.mock import Mock, patch

from iotlabcli import experiment
from iotlabcli.helpers import json_dumps
from iotlabcli.rest import Api

from .c23 import Mock, patch

API_RET = {"result": "test"}


Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/node_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

"""Test the iotlabcli.parser.node module"""

from unittest.mock import patch

import iotlabcli.parser.node as node_parser
from iotlabcli.tests.my_mock import MainMock

from .c23 import patch

# pylint: disable=too-many-public-methods
# pylint: disable=too-few-public-methods

Expand Down
3 changes: 1 addition & 2 deletions iotlabcli/tests/node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
# pylint: disable=no-member,maybe-no-member,too-many-statements
import json
import unittest
from unittest.mock import patch

from iotlabcli import node
from iotlabcli.tests import my_mock

from .c23 import patch


class TestNode(unittest.TestCase):
"""Test the 'iotlabcli.node' module"""
Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/profile_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
# Mock object not being recognized
# pylint: disable=no-member,maybe-no-member

from unittest.mock import patch

import iotlabcli.parser.profile as profile_parser
import iotlabcli.profile
from iotlabcli.tests.my_mock import MainMock

from .c23 import patch


class TestMainProfileParser(MainMock):
def test_main_add_parser(self):
Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/rest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
# pylint: disable=protected-access
import json
import unittest
from unittest.mock import patch
from urllib.error import HTTPError

from iotlabcli import rest
from iotlabcli.helpers import json_dumps
from iotlabcli.tests.my_mock import RequestRet

from .c23 import HTTPError, patch


class TestRest(unittest.TestCase):
"""Test the iotlabcli.rest module
Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/robot_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

"""Test the iotlabcli.parser.robot module"""

from unittest.mock import patch

import iotlabcli.parser.robot as robot_parser
from iotlabcli.tests.my_mock import MainMock

from .c23 import patch

# pylint: disable=too-many-public-methods
# pylint: disable=too-few-public-methods

Expand Down
4 changes: 2 additions & 2 deletions iotlabcli/tests/status_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

"""Test the iotlabcli.parser.status module"""

from unittest.mock import patch

import iotlabcli.parser.status as status_parser
from iotlabcli.tests.my_mock import MainMock

from .c23 import patch


@patch("iotlabcli.status.status_command")
class TestMainStatusParser(MainMock):
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ deps=
git+https://github.com/iot-lab/oml-plot-tools.git#egg=oml_plot_tools
git+https://github.com/iot-lab/ssh-cli-tools.git#egg=iotlabsshcli
git+https://github.com/iot-lab/aggregation-tools.git#egg=iotlabaggregator
-rtests_utils/test-requirements.txt
commands=
{[testenv:tests]commands}

Expand Down
Loading