How to use the bundlewrap.utils.Fault function in bundlewrap

To help you get started, we’ve selected a few bundlewrap 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 bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_nested_equal():
    def callback_a():
        return 'foo'
    def callback_b():
        return 'foo'

    a = Fault('id foo', callback_a).lower().b64encode()
    b = Fault('id foo', callback_b).lower().b64encode()
    assert id(a) != id(b)
    assert a == b
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_format_into():
    def callback():
        return 'foo'

    a = Fault('id foo', callback).format_into('This is my secret: "{}"')
    assert a.value == 'This is my secret: "foo"'
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_not_equal_b64encode():
    def callback_a():
        return 'foo'
    def callback_b():
        return 'foo'

    a = Fault('id foo', callback_a).b64encode()
    b = Fault('id bar', callback_b).b64encode()
    assert id(a) != id(b)
    assert a != b
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_nested_not_equal_because_of_operators():
    def callback_a():
        return 'foo'
    def callback_b():
        return 'foo'

    a = Fault('id foo', callback_a).lower().b64encode()
    b = Fault('id foo', callback_b).lower()
    assert id(a) != id(b)
    assert a != b
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_equal_lower():
    def callback_a():
        return 'foo'
    def callback_b():
        return 'foo'

    a = Fault('id foo', callback_a).lower()
    b = Fault('id foo', callback_b).lower()
    assert id(a) != id(b)
    assert a == b
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_order():
    def callback_a():
        return 'foo'
    def callback_b():
        return 'bar'
    def callback_c():
        return '0first'

    a = Fault('id foo', callback_a)
    b = Fault('id bar', callback_b)
    c = Fault('id 0first', callback_c)

    lst = sorted([a, b, c])

    assert lst[0].value == '0first'
    assert lst[1].value == 'bar'
    assert lst[2].value == 'foo'
github bundlewrap / bundlewrap / tests / unit / faults.py View on Github external
def test_add_plain_nonstring():
    def callback():
        return 4

    a = Fault('id foo', callback)
    b = a + 8
    assert b.value == 12
github bundlewrap / bundlewrap / bundlewrap / secrets.py View on Github external
def decrypt_file_as_base64(self, source_path, key=None):
        return Fault(
            'bw secrets decrypt_file_as_base64',
            self._decrypt_file_as_base64,
            source_path=source_path,
            key=key,
        )
github bundlewrap / bundlewrap / bundlewrap / metadata.py View on Github external
def default(self, obj):
        if isinstance(obj, Fault):
            return obj.value
        if isinstance(obj, set):
            return sorted(obj)
        if isinstance(obj, bytes):
            return force_text(obj)
        else:
            raise ValueError(_("illegal metadata value type: {}").format(repr(obj)))
github bundlewrap / bundlewrap / bundlewrap / utils / dicts.py View on Github external
def default(self, obj):
        if isinstance(obj, Fault):
            return self.default(obj.value)
        elif isinstance(obj, set):
            return sorted(obj)
        else:
            return JSONEncoder.default(self, obj)