Ejemplo n.º 1
0
    def test_yaml_includes_children_on_recursive_flag(self, mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {'path': '/foo/bar', 'data': {'bar': 'baz'}}

        def side_effect(arg):
            arg_value_dict = {'/': foo, '/foo/bar': foobar}
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "yaml",
                           "data": False,
                           "recursive": True})
        expected = {"/foo": {"children": [{"/foo/bar": {}}]}}
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == yaml.safe_dump(expected, default_flow_style=False)
Ejemplo n.º 2
0
    def test_dir_includes_grandchildren_on_recursive_flag(self,
                                                          mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {
            'path': '/foo/bar',
            'data': {'bar': 'baz'},
            'children': {'baz': 'foo'}
        }
        foobarbaz = {'path': '/foo/bar/baz'}

        def side_effect(arg):
            arg_value_dict = {
                '/': foo,
                '/foo/bar': foobar,
                '/foo/bar/baz': foobarbaz
            }
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "dir",
                           "data": False,
                           "recursive": True})
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == "/foo\n/foo/bar\n/foo/bar/baz"
Ejemplo n.º 3
0
    def test_json_includes_children_on_recursive_flag(self, mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {'path': '/foo/bar', 'data': {'bar': 'baz'}}

        def side_effect(arg):
            arg_value_dict = {'/': foo, '/foo/bar': foobar}
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "json",
                           "data": False,
                           "recursive": True})
        expected = {"/foo": {"children": [{"/foo/bar": {}}]}}
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == json.dumps(expected, sort_keys=True, indent=4,
                                    separators=(',', ': '))
Ejemplo n.º 4
0
    def test_dir_includes_grandchildren_on_recursive_flag(self,
                                                          mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {
            'path': '/foo/bar',
            'data': {'bar': 'baz'},
            'children': {'baz': 'foo'}
        }
        foobarbaz = {'path': '/foo/bar/baz'}

        def side_effect(arg):
            arg_value_dict = {
                '/': foo,
                '/foo/bar': foobar,
                '/foo/bar/baz': foobarbaz
            }
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "dir",
                           "data": False,
                           "recursive": True})
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == "/foo\n/foo/bar\n/foo/bar/baz"
Ejemplo n.º 5
0
    def test_json_includes_children_on_recursive_flag(self, mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {'path': '/foo/bar', 'data': {'bar': 'baz'}}

        def side_effect(arg):
            arg_value_dict = {'/': foo, '/foo/bar': foobar}
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "json",
                           "data": False,
                           "recursive": True})
        expected = {"/foo": {"children": [{"/foo/bar": {}}]}}
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == json.dumps(expected, sort_keys=True, indent=4,
                                    separators=(',', ': '))
Ejemplo n.º 6
0
    def test_yaml_includes_children_on_recursive_flag(self, mock_kazoo_class):
        foo = {
            'path': '/foo',
            'data': {'foo': 'bar'},
            'children': {'bar': {'foo': 'bar'}}
        }
        foobar = {'path': '/foo/bar', 'data': {'bar': 'baz'}}

        def side_effect(arg):
            arg_value_dict = {'/': foo, '/foo/bar': foobar}
            return arg_value_dict[arg]

        mock_kazoo_class.get.side_effect = side_effect
        fauxGflags = type('foo', (object,),
                          {"quiet": True,
                           "server": None,
                           "username": None,
                           "password": None,
                           "outputformat": "yaml",
                           "data": False,
                           "recursive": True})
        expected = {"/foo": {"children": [{"/foo/bar": {}}]}}
        get = Get(mock_kazoo_class)
        output = get.execute([], fauxGflags)
        assert output == yaml.safe_dump(expected, default_flow_style=False)
Ejemplo n.º 7
0
 def test_creates_simple_dir_outputformat(self, mock_kazoo_class):
     retval = {'path': '/foo'}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "dir",
                        "data": False,
                        "recursive": False})
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == "/foo"
Ejemplo n.º 8
0
 def test_creates_simple_dir_outputformat(self, mock_kazoo_class):
     retval = {'path': '/foo'}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "dir",
                        "data": False,
                        "recursive": False})
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == "/foo"
Ejemplo n.º 9
0
 def test_yaml_includes_data_on_data_flag(self, mock_kazoo_class):
     retval = {'path': '/foo', 'data': {'foo': 'bar'}}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "yaml",
                        "data": True,
                        "recursive": False})
     expected = {"/foo": {"data": {"foo": "bar"}}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == yaml.dump(expected, default_flow_style=False)
Ejemplo n.º 10
0
 def test_creates_simple_yaml_outputformat(self, mock_kazoo_class):
     retval = {'path': '/foo'}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "yaml",
                        "data": False,
                        "recursive": False})
     expected = {"/foo": {}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == yaml.dump(expected, default_flow_style=False)
Ejemplo n.º 11
0
 def test_yaml_includes_data_on_data_flag(self, mock_kazoo_class):
     retval = {'path': '/foo', 'data': {'foo': 'bar'}}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "yaml",
                        "data": True,
                        "recursive": False})
     expected = {"/foo": {"data": {"foo": "bar"}}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == yaml.dump(expected, default_flow_style=False)
Ejemplo n.º 12
0
 def test_creates_simple_yaml_outputformat(self, mock_kazoo_class):
     retval = {'path': '/foo'}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "yaml",
                        "data": False,
                        "recursive": False})
     expected = {"/foo": {}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == yaml.dump(expected, default_flow_style=False)
Ejemplo n.º 13
0
 def test_json_includes_data_on_data_flag(self, mock_kazoo_class):
     retval = {'path': '/foo', 'data': {'foo': 'bar'}}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "json",
                        "data": True,
                        "recursive": False})
     expected = {"/foo": {"data": {"foo": "bar"}}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == json.dumps(expected, sort_keys=True, indent=4,
                                 separators=(',', ': '))
Ejemplo n.º 14
0
 def test_creates_simple_json_outputformat(self, mock_kazoo_class):
     retval = {'path': '/foo'}
     mock_kazoo_class.get.return_value = retval
     fauxGflags = type('foo', (object,),
                       {"quiet": True,
                        "server": None,
                        "username": None,
                        "password": None,
                        "outputformat": "json",
                        "data": False,
                        "recursive": False})
     expected = {"/foo": {}}
     get = Get(mock_kazoo_class)
     output = get.execute([], fauxGflags)
     assert output == json.dumps(expected, sort_keys=True, indent=4,
                                 separators=(',', ': '))