Exemplo n.º 1
0
    def test_main_profile(self, list_nodes, node_command):
        """Run the parser.node.main function regarding profile."""
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # profile update
        args = ['--profile', 'profm3']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile', 123, [], 'profm3')

        # profile-load
        node_command.reset_mock()
        args = ['--profile-load', 'profile.json']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile-load', 123, [],
                                        'profile.json')

        # profile-reset
        node_command.reset_mock()
        args = ['--profile-reset']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile-reset', 123, [],
                                        None)
Exemplo n.º 2
0
    def test_main_profile(self, list_nodes, node_command):
        """Run the parser.node.main function regarding profile."""
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # profile update
        args = ['--profile', 'profm3']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile', 123, [], 'profm3')

        # profile-load
        node_command.reset_mock()
        args = ['--profile-load', 'profile.json']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile-load', 123, [],
                                        'profile.json')

        # profile-reset
        node_command.reset_mock()
        args = ['--profile-reset']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'profile-reset', 123, [],
                                        None)
Exemplo n.º 3
0
    def test_main_update(self, list_nodes, node_command):
        """Run the parser.node.main function regarding update."""
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # update with exclude list
        args = ['--update', 'tp.elf', '-e', 'grenoble,m3,1-2']
        list_nodes.return_value = ['m3-3']  # simplify
        node_parser.main(args)
        list_nodes.assert_called_with(
            self.api, 123, None,
            [['m3-1.grenoble.iot-lab.info', 'm3-2.grenoble.iot-lab.info']])
        node_command.assert_called_with(self.api, 'update', 123, ['m3-3'],
                                        'tp.elf')

        # update idle
        node_command.reset_mock()
        args = ['--update-idle']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'update-idle', 123, [], None)
Exemplo n.º 4
0
    def test_main_update(self, list_nodes, node_command):
        """Run the parser.node.main function regarding update."""
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # update with exclude list
        args = ['--update', 'tp.elf', '-e', 'grenoble,m3,1-2']
        list_nodes.return_value = ['m3-3']  # simplify
        node_parser.main(args)
        list_nodes.assert_called_with(
            self.api, 123, None,
            [['m3-1.grenoble.iot-lab.info', 'm3-2.grenoble.iot-lab.info']])
        node_command.assert_called_with(
            self.api, 'update', 123, ['m3-3'], 'tp.elf')

        # update idle
        node_command.reset_mock()
        args = ['--update-idle']
        list_nodes.return_value = []
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'update-idle', 123, [], None)
Exemplo n.º 5
0
    def test_main(self, list_nodes, node_command):
        """ Run the parser.node.main function """
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # start
        args = ['--start']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'start', 123, [], None)
        # stop
        args = ['--stop']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'stop', 123, [], None)

        # debug-start
        args = ['--debug-start']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'debug-start', 123, [], None)
        # debug-stop
        args = ['--debug-stop']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'debug-stop', 123, [], None)

        # Reset command with many arguments
        args = ['--reset', '-l', 'grenoble,m3,1-2', '-l', 'grenoble,m3,3']
        list_nodes.return_value = ['m3-1', 'm3-2', 'm3-3']  # simplify
        node_parser.main(args)
        list_nodes.assert_called_with(
            self.api, 123,
            [['m3-1.grenoble.iot-lab.info', 'm3-2.grenoble.iot-lab.info'],
             ['m3-3.grenoble.iot-lab.info']], None)
        node_command.assert_called_with(self.api, 'reset', 123,
                                        ['m3-1', 'm3-2', 'm3-3'], None)
Exemplo n.º 6
0
    def test_main(self, list_nodes, node_command):
        """ Run the parser.node.main function """
        node_command.return_value = {'result': 'test'}
        list_nodes.return_value = []

        # start
        args = ['--start']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'start', 123, [], None)
        # stop
        args = ['--stop']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'stop', 123, [], None)

        # debug-start
        args = ['--debug-start']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'debug-start', 123, [], None)
        # debug-stop
        args = ['--debug-stop']
        node_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, None, None)
        node_command.assert_called_with(self.api, 'debug-stop', 123, [], None)

        # Reset command with many arguments
        args = ['--reset', '-l', 'grenoble,m3,1-2', '-l', 'grenoble,m3,3']
        list_nodes.return_value = ['m3-1', 'm3-2', 'm3-3']  # simplify
        node_parser.main(args)
        list_nodes.assert_called_with(
            self.api, 123,
            [['m3-1.grenoble.iot-lab.info', 'm3-2.grenoble.iot-lab.info'],
             ['m3-3.grenoble.iot-lab.info']], None)
        node_command.assert_called_with(
            self.api, 'reset', 123, ['m3-1', 'm3-2', 'm3-3'], None)