Exemplo n.º 1
0
def test_nodeclassify_adds_argument_to_django_command_parser():
    mock_parser = mock.Mock()
    command = ncommand.Command()
    command.add_arguments(mock_parser)

    mock_parser.add_argument.assert_called_with("node_name",
                                                nargs="+",
                                                type=str)
Exemplo n.º 2
0
def test_nodeclassify_command_prints_yaml_for_valid_name(capsys):
    command = ncommand.Command()
    node = Node(name="TestNode")
    node.save()

    command.handle(None, node_name=["TestNode"])
    captured = capsys.readouterr()

    assert captured.out == VALID_YAML
Exemplo n.º 3
0
def test_nodeclassify_prints_yaml_on_missing_name(capsys):
    command = ncommand.Command()
    command.handle(None, node_name=["TestNode"])
    captured = capsys.readouterr()

    assert captured.out == VALID_YAML
Exemplo n.º 4
0
def test_nodeclassify_creates_new_node_on_missing_name():
    command = ncommand.Command()
    command.handle(None, node_name=["TestNode"])

    assert Node.objects.get(name="TestNode")
Exemplo n.º 5
0
def test_nodeclassify_exceptions_on_multi_parameter():
    command = ncommand.Command()
    with pytest.raises(Exception):
        command.handle(None, node_name=["Test", "Test2"])
Exemplo n.º 6
0
def test_nodeclassify_exceptions_on_invalid_parameter():
    command = ncommand.Command()
    with pytest.raises(Exception):
        command.handle(None, invalid=["Test"])