How to use the databand.parameters.DictParameter function in databand

To help you get started, we’ve selected a few databand examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_dict_parameter.py View on Github external
def test_parse(self):
        d = parameters.DictParameter()._p.parse_from_str(
            json.dumps(TestDictParameter._dict)
        )
        assert d == TestDictParameter._dict
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_dict_parameter.py View on Github external
def test_parse_invalid_input(self):
        with pytest.raises(ValueError):
            parameters.DictParameter()._p.parse_from_str('{"invalid"}')
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_dict_parameter.py View on Github external
def test_parse_and_serialize(self):
        inputs = [
            '{"username": "me", "password": "secret"}',
            '{"password": "secret", "username": "me"}',
        ]
        for json_input in inputs:
            _dict = parameters.DictParameter()._p.parse_from_str(json_input)
            assert json.loads(json_input) == _dict
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_dict_parameter.py View on Github external
# See the License for the specific language governing permissions and
# limitations under the License.
#

import collections
import json

import pytest

from databand import parameters
from dbnd.testing.helpers import build_task
from dbnd_test_scenarios.test_common.task.factories import TTask


class DictParameterTask(TTask):
    param = parameters.DictParameter()


class TestDictParameter(object):
    _dict = collections.OrderedDict([("username", "me"), ("password", "secret")])

    def test_parse(self):
        d = parameters.DictParameter()._p.parse_from_str(
            json.dumps(TestDictParameter._dict)
        )
        assert d == TestDictParameter._dict

    def test_parse_and_serialize(self):
        inputs = [
            '{"username": "me", "password": "secret"}',
            '{"password": "secret", "username": "me"}',
        ]