Exemplo n.º 1
0
    def test_delete_error(self, request, monkeypatch):
        """Pass."""
        delete_me = {
            "adapter_name": "badwolf",
            "adapter_name_raw": "badwolf",
            "config_raw": {},
            "node_id": "badwolf",
            "node_name": "badwolf",
            "id": "badwolf",
            "uuid": "badwolf",
            "status": "badwolf",
            "error": "badwolf",
        }
        runner = utils.load_clirunner(request, monkeypatch)

        args1 = [
            "adapters", "cnx", "delete", "--rows", "-", "--force", "--wait",
            "0"
        ]
        result1 = runner.invoke(cli=cli.cli,
                                args=args1,
                                input=tools.json_dump(delete_me))
        stderr1 = result1.stderr
        stdout1 = result1.stdout
        exit_code1 = result1.exit_code

        assert stdout1
        assert stderr1
        assert exit_code1 == 1

        json1 = tools.json_load(stdout1)
        assert isinstance(json1, tools.LIST)
Exemplo n.º 2
0
    def test_non_adapters_json(self, request, monkeypatch):
        """Pass."""
        runner = utils.load_clirunner(request, monkeypatch)

        content = [{"x": "a"}]

        args1 = ["adapters", "cnx", "get", "--rows", "-"]
        result1 = runner.invoke(cli=cli.cli,
                                args=args1,
                                input=tools.json_dump(content))

        stderr1 = result1.stderr
        stdout1 = result1.stdout
        exit_code1 = result1.exit_code

        assert not stdout1
        assert stderr1
        assert exit_code1 != 0

        errlines1 = stderr1.splitlines()

        exp = "  Item must have keys:"
        assert errlines1[-2].startswith(exp)
Exemplo n.º 3
0
 def test_dump_error_true(self):
     """Simple test."""
     x = pytest
     with pytest.raises(Exception):
         json_dump(obj=x, error=True)
Exemplo n.º 4
0
 def test_dump_error_false(self):
     """Simple test."""
     x = pytest
     y = json_dump(obj=x, error=False)
     assert y == pytest
Exemplo n.º 5
0
 def test_dump_bytes(self):
     """Simple test."""
     x = b"xxx"
     y = json_dump(obj=x)
     assert y == '"xxx"'
Exemplo n.º 6
0
 def test_dump(self):
     """Simple test."""
     x = {"x": 2}
     y = json_dump(obj=x)
     assert y == '{\n  "x": 2\n}'
def to_json(ctx, raw_data, **kwargs):
    """Pass."""
    return tools.json_dump(obj=raw_data, **kwargs)