Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b524c39 authored by Zach Johnson's avatar Zach Johnson
Browse files

Replace direct usages of acl manager stream with acl link instead

Also migrate some asserts to cert.truth

Test: cert/run --host --test_filter=L2capTest
Change-Id: I36446c92f5ea57807129b25322a2e5de3af50981
parent b4ba004f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ class PyAclManagerAclConnection(IEventStream, Closable):
        self.device = device
        self.handle = handle
        # todo enable filtering after sorting out handles
        self.our_acl_stream = FilteringEventStream(acl_stream, None)
        #self.our_acl_stream = FilteringEventStream(acl_stream, None)
        self.our_acl_stream = acl_stream

        if remote_addr:
            remote_addr_bytes = bytes(
+28 −9
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#   limitations under the License.

import time
from datetime import timedelta

from mobly.asserts import assert_true
from mobly.asserts import assert_false
@@ -56,35 +57,49 @@ class ObjectSubject(object):
                "Expected \"%s\" to not be None" % self._value, extras=None)


DEFAULT_TIMEOUT = timedelta(seconds=3)


class EventStreamSubject(ObjectSubject):

    def __init__(self, value):
        super().__init__(value)

    def emits(self, *match_fns):
    def emits(self, *match_fns, at_least_times=1, timeout=DEFAULT_TIMEOUT):
        if len(match_fns) == 0:
            raise signals.TestFailure("Must specify a match function")
        elif len(match_fns) == 1:
            NOT_FOR_YOU_assert_event_occurs(self._value, match_fns[0])
            NOT_FOR_YOU_assert_event_occurs(
                self._value,
                match_fns[0],
                at_least_times=at_least_times,
                timeout=timeout)
            return EventStreamContinuationSubject(self._value)
        else:
            return MultiMatchStreamSubject(self._value, match_fns)
            return MultiMatchStreamSubject(self._value, match_fns, timeout)


class MultiMatchStreamSubject(object):

    def __init__(self, stream, match_fns):
    def __init__(self, stream, match_fns, timeout):
        self._stream = stream
        self._match_fns = match_fns
        self._timeout = timeout

    def inAnyOrder(self):
        NOT_FOR_YOU_assert_all_events_occur(
            self._stream, self._match_fns, order_matters=False)
            self._stream,
            self._match_fns,
            order_matters=False,
            timeout=self._timeout)
        return EventStreamContinuationSubject(self._stream)

    def inOrder(self):
        NOT_FOR_YOU_assert_all_events_occur(
            self._stream, self._match_fns, order_matters=True)
            self._stream,
            self._match_fns,
            order_matters=True,
            timeout=self._timeout)
        return EventStreamContinuationSubject(self._stream)


@@ -93,14 +108,18 @@ class EventStreamContinuationSubject(ObjectSubject):
    def __init__(self, value):
        super().__init__(value)

    def then(self, *match_fns):
    def then(self, *match_fns, at_least_times=1, timeout=DEFAULT_TIMEOUT):
        if len(match_fns) == 0:
            raise signals.TestFailure("Must specify a match function")
        elif len(match_fns) == 1:
            NOT_FOR_YOU_assert_event_occurs(self._value, match_fns[0])
            NOT_FOR_YOU_assert_event_occurs(
                self._value,
                match_fns[0],
                at_least_times=at_least_times,
                timeout=timeout)
            return EventStreamContinuationSubject(self._value)
        else:
            return MultiMatchStreamSubject(self._value, match_fns)
            return MultiMatchStreamSubject(self._value, match_fns, timeout)


class BooleanSubject(ObjectSubject):
+113 −190

File changed.

Preview size limit exceeded, changes collapsed.