Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_inequality(self, first, second, context):
assume(first != second)
assert reader.value(first)(context) != reader.value(second)(context)
def f():
a = yield reader.value(2)
b = yield reader.value(2)
return a + b
def test_identity_law(self, value, context):
assert (
reader.value(value).map(identity)(context) == reader.value(value)
(context)
)
def test_right_identity_law(self, value, context):
assert (
reader.value(value).and_then(
reader.value
).run(context) == reader.value(value).run(context)
)
assert reader.filter_m(lambda v: reader.value(v % 2 == 0),
range(3)).run(None) == (0, 2)
def test_composition_law(self, f, g, value, context):
h = compose(f, g)
assert (
reader.value(value).map(h)(context) ==
reader.value(value).map(g).map(f)(context)
)
def test_equality(self, value, context):
assert reader.value(value).run(context) == reader.value(value
).run(context)
def get_user(user_id: int) -> DBAction[User]:
return value(User(user_id, 'pa$$word'))
def update_password(user: User, t: Transaction) -> DBAction[bool]:
user = user.clone(password=new_password)
t.add(user)
return value(True)