ViaQ / watches-cli

:watch: CLI tool to pull statistics from Elasticsearch
Apache License 2.0
1 stars 1 forks source link

Add option to transform JSON response #29

Closed lukas-vlcek closed 7 years ago

lukas-vlcek commented 7 years ago

Most commands accept --transform=nested option. It transforms JSON response to nested data (this means the JSON does not contain data as a JSON keys).

Make tests pass on clusters with more than one node.

Closes #24

lukas-vlcek commented 7 years ago

@richm PTAL

lukas-vlcek commented 7 years ago

@richm I did some modifications. The option is called --transform=nested now and the code is more general & prepared to support more transformation types in the future.

richm commented 7 years ago

Add a test like this e.g. to tests/commands/test_cluster_state.py:


    def test_bogus_transform_value(self):
        cmd = self.appendSecurityCommands(['watches', 'cluster_state', '--transform=bogus'])
        output, errout = popen(cmd, stdout=PIPE, stderr=PIPE).communicate()
        self.assertRegexpMatches(errout, '(?ms)ERROR:.*RuntimeError: Unsupported transform type')

I think you only need to add a test like this to one of the commands that supports the --transform argument.

lukas-vlcek commented 7 years ago

Done (in tests/commands/test_cluster_health.py).