def test_comparison(self):
        q2_2013 = Quarter.parse("2013_q2")
        q1_2013 = Quarter.parse("2013_q1")
        q4_2012 = Quarter.parse("2012_q4")

        assert_that(q4_2012, is_(less_than(q1_2013)))
        assert_that(q1_2013, is_(less_than(q2_2013)))
        assert_that(q1_2013, is_(greater_than(q4_2012)))
        assert_that(q2_2013, is_(greater_than(q1_2013)))
        assert_that(q2_2013, is_(equal_to(q2_2013)))
Ejemplo n.º 2
0
 def test_version_comparison(self):
     """Testing comparison of versions."""
     version = Version("1.2")
     assert_that(version, equal_to(version))
     assert_that(Version("1.2"), equal_to(Version("1.2")))
     assert_that(Version("1.2"), less_than(Version("1.3")))
     assert_that(Version("1.2"), less_than(Version("1.2.1")))
     assert_that(Version("1.3"), is_not(less_than(Version("1.2"))))
     assert_that(Version("1.3") == 1.3, equal_to(False))
     assert_that(
         calling(Version("1.3").__lt__).with_args(1.3),
         raises(TypeError, "Comparing type Version with incomaptible type"))
 def test_can_maximize_window(self):
     wait = WebDriverWait(self.driver, 25)
     self.load_test_page()
     self.driver.set_window_size(375, 667)
     wait.until(lambda x: windows_size_is(x, 375, 667), message="windows size should be 375x667")
     size_before = self.driver.get_window_size()
     self.driver.maximize_window()
     wait.until(lambda x: windows_size_greater_than(x, 375, 667), message="windows size should be greater 375x667")
     size_after = self.driver.get_window_size()
     assert_that(int(size_before['width']), less_than(int(size_after['width'])),
                 "screen width should be bigger after resizing")
     assert_that(int(size_before['height']), less_than(int(size_after['height'])),
                 "screen height should be bigger after resizing")
Ejemplo n.º 4
0
 def test_double_enable(self):
     cli = self.perf_mon()
     c = []
     cli.enable_perf_metric(0.1, lambda: c.append(1))
     sleep(0.5)
     assert_that(len(c), greater_than(1))
     assert_that(len(c), less_than(8))
     cli.enable_perf_metric(10, lambda: c.append(1))
     sleep(0.5)
     assert_that(len(c), less_than(10))
     cli.disable_perf_metric()
     assert_that(cli.prev_counter, none())
     assert_that(cli.curr_counter, none())
     assert_that(cli.is_perf_metric_enabled(), equal_to(False))
Ejemplo n.º 5
0
def test_get_run_ids_uses_the_correct_min_and_max_dates_in_its_response(mock_get, _mock_print):
    get_run_ids(100, "test-url", "test-token")

    check_mocked_functions_called(mock_get)
    request_args = mock_get.call_args

    expected_date_time = datetime.datetime.now()
    actual_date_time = request_args[1]["params"]["maxLastUpdatedDate"]
    time_difference = (actual_date_time - expected_date_time).total_seconds()
    assert_that(time_difference, less_than(2), "maxLastUpdatedDate incorrect")

    expected_date_time = get_date_altered_by_days(-1, datetime.datetime.now())
    actual_date_time = request_args[1]["params"]["minLastUpdatedDate"]
    time_difference = (actual_date_time - expected_date_time).total_seconds()
    assert_that(time_difference, less_than(2), "minLastUpdatedDate incorrect")
Ejemplo n.º 6
0
 def price_is_within_set_brackets(self, min_val, max_val):
     page = MorizonOfferPage(self._driver).wait_for_page_to_load()
     assert_that(page.is_page_displayed(),
                 "A page with the offer is not displayed")
     actual_price = page.get_price()
     assert_that(actual_price, less_than(max_val))
     assert_that(actual_price, greater_than(min_val))
Ejemplo n.º 7
0
    def check_nets_count_difference_for_agents(self, dhcp_agents,
                                               max_difference_in_percent):
        """Step to check networks count for DHCP agent.

        This step verifies that the difference between max and min
        networks count for all DHCP agents is less than max allowed percent.
        Max networks count is considered to be 100%.

        Args:
            dhcp_agents (list): list of neutron agents dicts
            max_percentage_difference (int): max allowed percentage for
                difference between max and min nets counts for agents

        Raises:
            AssertionError: if check failed
        """
        def _count_percent_difference(min_val, max_val):
            diff = max_val - min_val
            result = (100 * diff) / float(max_val)
            return round(result)

        networks_count_on_agent = []

        for dhcp_agent in dhcp_agents:
            agent_networks = self.get_networks_for_dhcp_agent(dhcp_agent)
            networks_count_on_agent.append(len(agent_networks))

        min_count = min(networks_count_on_agent)
        max_count = max(networks_count_on_agent)
        actual_percentage_difference = _count_percent_difference(
            min_count, max_count)
        assert_that(actual_percentage_difference,
                    is_(less_than(max_difference_in_percent)))
Ejemplo n.º 8
0
    def test__shouldReturnApprovalsOnTimeWhenTooManyWorkflowObject(self):
        authorized_permission = PermissionObjectFactory()
        authorized_user = UserObjectFactory(
            user_permissions=[authorized_permission])

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")

        workflow = WorkflowFactory(initial_state=state1,
                                   content_type=self.content_type,
                                   field_name="my_field")

        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta,
            priority=0,
            permissions=[authorized_permission])

        self.objects = BasicTestModelObjectFactory.create_batch(
            250, workflow=workflow)
        before = datetime.now()
        BasicTestModel.river.my_field.get_on_approval_objects(
            as_user=authorized_user)
        after = datetime.now()
        assert_that(after - before, less_than(timedelta(milliseconds=200)))
        print("Time taken %s" % str(after - before))
Ejemplo n.º 9
0
 def _select_comparison_method(self, left, right, comparison_type):
     if comparison_type == Types.EQUAL:
         assert_that(left, equal_to(right))
     elif comparison_type == Types.NOT_EQUAL:
         assert_that(left, is_not(equal_to(right)))
     elif comparison_type == Types.LESS_THAN:
         assert_that(left, less_than(right))
     elif comparison_type == Types.LESS_THAN_EQUAL:
         assert_that(left, less_than_or_equal_to(right))
     elif comparison_type == Types.GREATER_THAN:
         assert_that(left, greater_than(right))
     elif comparison_type == Types.GREATER_THAN_EQUAL:
         assert_that(left, greater_than_or_equal_to(right))
     elif comparison_type == Types.IS:
         assert_that(left, is_(right))
     elif comparison_type == Types.IS_NOT:
         assert_that(left, is_not(right))
     elif comparison_type == Types.IN:
         assert_that(left, is_in(right))
     elif comparison_type == Types.NOT_IN:
         assert_that(left, is_not(is_in(right)))
     elif comparison_type == Types.MATCHES_REGEXP:
         assert_that(left, matches_regexp(right))
     else:
         raise Exception()
Ejemplo n.º 10
0
    def test_zero(self):
        czv = ConstantZeroValue()
        assert_that(czv, is_(same_instance(ConstantZeroValue())))
        assert_that(czv, has_property('value', 0))

        # equality
        assert_that(czv, is_(czv))
        v = NumericMaximum()
        assert_that(czv, is_(v))
        assert_that(v, is_(czv))

        v.value = -1
        assert_that(v, is_(less_than(czv)))

        v.value = 1
        assert_that(v, is_(greater_than(czv)))

        czv.value = 1
        assert_that(czv, has_property('value', 0))

        czv.set(2)
        assert_that(czv, has_property('value', 0))

        assert_that(calling(pickle.dumps).with_args(czv),
                    raises(TypeError))
        assert_that(calling(czv._p_resolveConflict).with_args(None, None, None),
                    raises(NotImplementedError))
def test_get_current_datetime():
    expected_date_time = datetime.datetime.now()

    actual_date_time = get_current_datetime()
    time_difference = (actual_date_time - expected_date_time).microseconds

    assert_that(time_difference, less_than(1000), "Current date time incorrect")
Ejemplo n.º 12
0
def impl(context):
    observer = context.observer

    hp_events = [
        x for x in observer.events if e_event_type(x) == 'hit points changed'
    ]

    hp_event = hp_events[0]

    attack_events = [
        x for x in observer.events if e_event_type(x) == 'attack hit'
    ]

    if attack_events:
        attack_event = attack_events[0]

        weapon = e_attacker(attack_event).inventory.weapon

        expected_damage = sum(x[0] for x in weapon.weapon_data.damage)
        realised_damage = e_old_hit_points(hp_event) - e_new_hit_points(
            hp_event)

    else:
        trap_event = [
            x for x in observer.events
            if e_event_type(x) == 'damage trap triggered'
        ][0]
        expected_damage = 2
        realised_damage = e_damage(trap_event)[0]

    assert_that(realised_damage, is_(less_than(expected_damage)))
Ejemplo n.º 13
0
    def test_capped_data_set_is_capped(self):
        self.engine.create_data_set('foo_bar', 1)

        for i in range(100):
            self.engine.save_record('foo_bar', {'foo': i})

        assert_that(len(self.engine.execute_query('foo_bar', Query.create())),
                    less_than(70))
Ejemplo n.º 14
0
    def test_is_not_less_than(self):

        for attr in ("time", "state"):
            with self.subTest(attr=attr):
                args = {"time": 0, "state": 0, "action": 0}
                first = ActionState(**args)

                assert_that(first, is_not(less_than(first)))
Ejemplo n.º 15
0
 def test_can_maximize_window(self):
     wait = WebDriverWait(self.driver, 25)
     self.load_test_page()
     self.driver.set_window_size(375, 667)
     wait.until(lambda x: windows_size_is(x, 375, 667),
                message="windows size should be 375x667")
     size_before = self.driver.get_window_size()
     self.driver.maximize_window()
     wait.until(lambda x: windows_size_greater_than(x, 375, 667),
                message="windows size should be greater 375x667")
     size_after = self.driver.get_window_size()
     assert_that(int(size_before['width']),
                 less_than(int(size_after['width'])),
                 "screen width should be bigger after resizing")
     assert_that(int(size_before['height']),
                 less_than(int(size_after['height'])),
                 "screen height should be bigger after resizing")
def lower_than_threshold(context):
    context.iterator.current_value = 8
    prior_threshold = context.iterator
    context.iterator.current_value = 5
    
    assert_that(context.iterator.threshold,
                is_(less_than(prior_threshold)))
    return
Ejemplo n.º 17
0
    def runTest(self):
        self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3)))

        self.mock_of_thing.baz(0)
        self.mock_of_thing.baz(1)
        self.mock_of_thing.baz(2)
        self.assertRaises(UnexpectedMethodCall,
                          self.mock_of_thing.baz,
                          3)
        self.assertRaises(UnexpectedMethodCall,
                          self.mock_of_thing.baz,
                          4)

        self.mock_of_thing.baz(-1)
Ejemplo n.º 18
0
    def runTest(self):
        self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3)))
        self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3)))

        self.mock_of_thing.baz(oneval=0)
        self.mock_of_thing.baz(oneval=1)
        self.mock_of_thing.baz(oneval=2)
        self.assertRaises(UnexpectedMethodCall,
                          self.mock_of_thing.baz,
                          oneval=3)
        self.assertRaises(UnexpectedMethodCall,
                          self.mock_of_thing.baz,
                          4)

        self.mock_of_thing.baz(oneval=-1)
Ejemplo n.º 19
0
 def test_optimized_bubble_sort(self):
     sorted_list = list(range(1000))
     t1 = timeit(lambda: bubble_sort(sorted_list), number=1)
     print(t1)
     reversed_list = list(reversed(range(1000)))
     t2 = timeit(lambda: bubble_sort(reversed_list), number=1)
     print(t2)
     assert_that(t1 * 3, less_than(t2))
Ejemplo n.º 20
0
    def test__shouldMigrationForIterationMustFinishInShortAmountOfTimeWithTooManyObject(self):
        out = StringIO()
        sys.stout = out
        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")
        state3 = StateObjectFactory(label="state3")
        state4 = StateObjectFactory(label="state4")

        workflow = WorkflowFactory(initial_state=state1, content_type=ContentType.objects.get_for_model(BasicTestModel), field_name="my_field")
        transition_meta_1 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state1,
        )

        transition_meta_2 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state2,
            destination_state=state3,
        )

        transition_meta_3 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state2,
            destination_state=state4,
        )

        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_1,
            priority=0
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_2,
            priority=0
        )

        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_2,
            priority=1
        )

        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_3,
            priority=0
        )

        BasicTestModelObjectFactory.create_batch(250)

        call_command('migrate', 'river', '0006', stdout=out)

        before = datetime.now()
        call_command('migrate', 'river', '0007', stdout=out)
        after = datetime.now()
        assert_that(after - before, less_than(timedelta(minutes=5)))
Ejemplo n.º 21
0
    def test_capped_data_set_is_capped(self):
        self.engine.create_data_set('foo_bar', 1)

        for i in range(100):
            self.engine.save_record('foo_bar', {'foo': i})

        assert_that(
            len(self.engine.execute_query('foo_bar', Query.create())),
            less_than(70))
def test_efficiently_displays_image_cover_when_it_does_not_change(driver):
    album = make_album(images=[
        make_image("image/jpeg", _load_test_image("big-image.jpg"),
                   Image.FRONT_COVER)
    ])
    page = show_page(album)

    time = timeit.timeit(lambda: page.display(album), number=50)
    assert_that(time, less_than(1), "time to execute render 50 times")
Ejemplo n.º 23
0
    def test_adding_items(self):
        """
        Test basic case of adding items on the level
        """
        assert_that(list(get_items(self.level)), has_length(greater_than(3)))
        assert_that(list(get_items(self.level)), has_length(less_than(6)))

        assert_that(self.level, does_have_item('dagger',
                                               greater_than_or_equal_to(3)))
        assert_that(self.level, does_have_item('red potion', 1))
Ejemplo n.º 24
0
    def test_rate_tracker_decrements(self):
        github_session = GithubSession()
        github_session.set_credentials(
            personal_access_token=self.__personal_access_token)
        github_session.request_api('/')
        rate_before = github_session.rate
        github_session.request_api('/')
        rate_after = github_session.rate

        assert_that(rate_after, is_(less_than(rate_before)))
Ejemplo n.º 25
0
def step_then_a_core_props_part_with_def_vals_is_added(context):
    core_props = context.prs.core_properties
    assert_that(core_props.title, is_('PowerPoint Presentation'))
    assert_that(core_props.last_modified_by, is_('python-pptx'))
    assert_that(core_props.revision, is_(1))
    # core_props.modified only stores time with seconds resolution, so
    # comparison needs to be a little loose (within two seconds)
    modified_timedelta = datetime.utcnow() - core_props.modified
    max_expected_timedelta = timedelta(seconds=2)
    assert_that(modified_timedelta, less_than(max_expected_timedelta))
Ejemplo n.º 26
0
def step_then_a_core_props_part_with_def_vals_is_added(context):
    core_props = context.prs.core_properties
    assert_that(core_props.title, is_('PowerPoint Presentation'))
    assert_that(core_props.last_modified_by, is_('python-pptx'))
    assert_that(core_props.revision, is_(1))
    # core_props.modified only stores time with seconds resolution, so
    # comparison needs to be a little loose (within two seconds)
    modified_timedelta = datetime.utcnow() - core_props.modified
    max_expected_timedelta = timedelta(seconds=2)
    assert_that(modified_timedelta, less_than(max_expected_timedelta))
Ejemplo n.º 27
0
def test_suite_times(report_for):
    start = time.time()

    report = report_for("""
    def test():
        assert True
    """)

    stop = time.time()

    assert_that(report.get('start'), has_float(all_of(
        greater_than(start * 1000),
        less_than(float(report.get('stop')))
    )))

    assert_that(report.get('stop'), has_float(all_of(
        greater_than(float(report.get('start'))),
        less_than(stop * 1000),
    )))
Ejemplo n.º 28
0
def between(lower: Any,
            upper: Any,
            lower_inclusive=True,
            upper_inclusive=True) -> Matcher[Any]:
    """TODO"""
    return all_of(
        greater_than_or_equal_to(lower)
        if lower_inclusive else greater_than(lower),
        less_than_or_equal_to(upper) if upper_inclusive else less_than(upper),
    )
Ejemplo n.º 29
0
    def test_is_less_than(self):

        for attr in ("time", "state"):
            with self.subTest(attr=attr):
                args = {"time": 0, "state": 0, "action": 0}
                first = ActionState(**args)
                args[attr] = 1
                second = ActionState(**args)

                assert_that(first, less_than(second))
Ejemplo n.º 30
0
    def test_adding_items(self):
        """
        Test basic case of adding items on the level
        """
        assert_that(list(get_items(self.level)), has_length(greater_than(3)))
        assert_that(list(get_items(self.level)), has_length(less_than(6)))

        assert_that(self.level,
                    does_have_item('dagger', greater_than_or_equal_to(3)))
        assert_that(self.level, does_have_item('red potion', 1))
Ejemplo n.º 31
0
    def test_it_should_calculate_0_as_distance_to_same_point(self):
        """Check it actually computes distances"""
        position = AVAILABLE_STATION['latitud'], AVAILABLE_STATION['longitud']
        result = self.filter(distance(position),
                             (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(result, contains(
            has_property('distance', 0.0),
            has_property('distance', all_of(greater_than(1401), less_than(1402)))
        ))
Ejemplo n.º 32
0
def test_test_times(report_for, stmt):
    start = time.time()

    report = report_for("""
    def test():
        %s
    """ % stmt)

    stop = time.time()

    assert_that(report.find('.//test-case').attrib, has_entries(start=has_float(greater_than(start * 1000)),
                                                                stop=has_float(less_than(stop * 1000))))
Ejemplo n.º 33
0
    def test_it_should_calculate_0_as_distance_to_same_point(self):
        """Check it actually computes distances"""
        position = AVAILABLE_STATION['latitud'], AVAILABLE_STATION['longitud']
        result = self.filter(distance(position),
                             (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(
            result,
            contains(
                has_property('distance', 0.0),
                has_property('distance',
                             all_of(greater_than(1401), less_than(1402)))))
Ejemplo n.º 34
0
def impl(context, character_name, delta, armour_name):
    character = get_character(context, character_name)
    armour = get_item(context, armour_name)

    if delta == 'slower':
        assert_that(character.tick,
                    is_(greater_than(character.speed * Duration.fast)))
    elif delta == 'faster':
        assert_that(character.tick,
                    is_(less_than(character.speed * Duration.fast)))
    else:
        assert False
Ejemplo n.º 35
0
    def test_answer_blocking(self):
        device = Device(ip='127.0.0.1')
        snom_controller = SnomController(self._ami_class)
        answerer = Mock(_SnomAnswerer)
        snom_controller._get_answerer = Mock(return_value=answerer)
        answerer.answer.side_effect = lambda: time.sleep(0.2)

        call_time = time.time()
        snom_controller.answer(device)
        return_time = time.time()

        elapsed_time = return_time - call_time
        assert_that(elapsed_time, less_than(0.1), 'Time spent in a blocking answer in second')
    def test_parameters_can_be_passed_through_the_command_line(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("brocade"))
            start_time = time.time()

            create_session(client, "session_timeouting")

            create_session(client, "session_taking_over")

            result = client.delete("/switches-sessions/session_taking_over")
            assert_that(result.status_code, is_(204), result.text)

            assert_that(time.time() - start_time, is_(less_than(3)))
    def test_parameters_can_be_passed_through_the_command_line(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("brocade"))
            start_time = time.time()

            create_session(client, "session_timeouting")

            create_session(client, "session_taking_over")

            result = client.delete("/switches-sessions/session_taking_over")
            assert_that(result.status_code, is_(204), result.text)

            assert_that(time.time() - start_time, is_(less_than(3)))
Ejemplo n.º 38
0
    def test_answer_blocking(self):
        device = Device(ip='127.0.0.1')
        snom_controller = SnomController(self._ami_class)
        answerer = Mock(_SnomAnswerer)
        snom_controller._get_answerer = Mock(return_value=answerer)
        answerer.answer.side_effect = lambda: time.sleep(0.2)

        call_time = time.time()
        snom_controller.answer(device)
        return_time = time.time()

        elapsed_time = return_time - call_time
        assert_that(elapsed_time, less_than(0.1),
                    'Time spent in a blocking answer in second')
Ejemplo n.º 39
0
    def test_receive(self):
        self.driver.read.side_effect = [[0xFF, 0x1E, 0x02], [0x48, 0x69]
                                        ] + EMPTY_READS
        start_time = self.current_time

        data = self.serial.receive()

        assert_that(data, is_([0x48, 0x69]))
        assert_that(self.driver.read, called_with(3))
        assert_that(self.driver.read, called_with(2))

        elapsed_time = self.current_time - start_time
        assert_that(elapsed_time, greater_than(timedelta(milliseconds=100)))
        assert_that(elapsed_time, less_than(timedelta(milliseconds=200)))
Ejemplo n.º 40
0
    def command(self, cmdline, **kargs):
        cmd = Command(self, cmdline, **kargs)
        cmd.caller = CallerData()

        if cmd.timeout is not None:
            assertion = DeferredAssertion(
                self, cmd, ran_for_time(hamcrest.less_than(cmd.timeout)))
            assertion.caller = CallerData()

        if cmd.expected is not None:
            assertion = DeferredAssertion(self, cmd, exits_with(cmd.expected))
            assertion.caller = CallerData()

        return cmd
Ejemplo n.º 41
0
def test_suite_times(report_for):
    start = time.time()

    report = report_for("""
    def test():
        assert True
    """)

    stop = time.time()

    assert_that(
        report.get('start'),
        has_float(
            all_of(greater_than(start * 1000),
                   less_than(float(report.get('stop'))))))

    assert_that(
        report.get('stop'),
        has_float(
            all_of(
                greater_than(float(report.get('start'))),
                less_than(stop * 1000),
            )))
Ejemplo n.º 42
0
def test_test_times(report_for, stmt):
    start = time.time()

    report = report_for("""
    def test():
        %s
    """ % stmt)

    stop = time.time()

    assert_that(
        report.find('.//test-case').attrib,
        has_entries(start=has_float(greater_than(start * 1000)),
                    stop=has_float(less_than(stop * 1000))))
Ejemplo n.º 43
0
    def _check_across_funcs(self, before_all, f1, f2, f3):
        from nti.testing.time import _real_time
        after_first = f1()

        assert_that(after_first, is_(greater_than(before_all)))

        after_second = f2()
        current_real = _real_time()

        # The loop in self._check_time incremented the clock by a full second.
        # That function should have taken far less time to actually run than that, though,
        # so the real time function should be *behind*
        assert_that(current_real, is_(less_than(after_second)))


        # And immediately running it again will continue to produce values that
        # are ever larger.
        after_second = f2()
        current_real = _real_time()

        assert_that(current_real, is_(less_than(after_second)))

        assert_that(after_second, is_(greater_than(before_all)))
        assert_that(after_second, is_(greater_than(after_first)))

        # We are now some number of seconds ahead. If we're the only ones calling
        # time.time(), it would be about 3. But we're not, various parts of the lib
        # apparently are calling time.time() too, which makes it unpredictable.
        # We don't want to sleep for a long time, so we
        # reset the clock again to prove that we can go back to real time.

        # Use a value in the distant past to account for the calls that get made.
        reset_monotonic_time(-50)

        after_third = f3()
        current_real = _real_time()
        assert_that(current_real, is_(greater_than_or_equal_to(after_third)))
Ejemplo n.º 44
0
def expect_keypoints_detections_for_every_frame_accurate_within_margin_of_error(
        expected_result, result, video_dims):
    result_boxes = result["boxes"]
    result_kps = result["keypoints"]
    expected_kps = expected_result["keypoints"]
    cls_ix_person = get_person_class_index()
    result_kps_track_one = track_one(result_boxes, result_kps,
                                     cls_ix_person)["keypoints"]
    missed_frame_error = 1.0  # TODO: normalize all errors
    normalizer = np.ones((2, 17))
    normalizer[0] = normalizer[0] * video_dims[0]
    normalizer[1] = normalizer[1] * video_dims[1]
    frames_sqe = []
    for frame, pair in enumerate(zip(result_kps_track_one, expected_kps)):
        frame_res = pair[0]
        frame_gt = pair[1]
        # number of detections in the ground-truth data
        # needs to be at most 1 per frame.
        # This does NOT imply detectron is supposed to detect
        # no more than one person per frame.
        # Rather, the ground-truth data is polished to ensure
        # a single 'tracked' subject
        assert_that(
            len(frame_gt),
            less_than(2),
            "number of detections in ground truth (should be at most 1 per frame)",
        )
        # in result from track_one, every frame should have either
        #    - a list with *ONE* set of keypoints
        #    or
        #    - an empty list
        if len(frame_res) != len(frame_gt):
            frames_sqe.append(missed_frame_error)
            continue
        if len(frame_res) == 0:
            # correctly detected frame with no person
            # from each frame, we want the keypoints
            # and then only the first two elements, x and y
            continue
        frame_res = frame_res[0][2:]
        frame_gt = frame_gt[0][2:]
        fsqe = np.sum(((frame_res - frame_gt) / normalizer)**2)
        frames_sqe.append(fsqe)
    frames_sqe = np.array(frames_sqe, dtype=float)
    msqe = np.mean(frames_sqe)
    max_normalized_error = 0.03
    msqe | should.be_less_than(
        max_normalized_error
    )  # temp, must normalize error and come up w a max for msqe
Ejemplo n.º 45
0
 def test_it_can_construct_default_core_props(self):
     core_props = CoreProperties.default()
     # verify -----------------------
     assert_that(core_props, is_(instance_of(CoreProperties)))
     assert_that(core_props.content_type, is_(CT.OPC_CORE_PROPERTIES))
     assert_that(core_props.partname, is_('/docProps/core.xml'))
     assert_that(core_props._element, is_(instance_of(CT_CoreProperties)))
     assert_that(core_props.title, is_('PowerPoint Presentation'))
     assert_that(core_props.last_modified_by, is_('python-pptx'))
     assert_that(core_props.revision, is_(1))
     # core_props.modified only stores time with seconds resolution, so
     # comparison needs to be a little loose (within two seconds)
     modified_timedelta = datetime.utcnow() - core_props.modified
     max_expected_timedelta = timedelta(seconds=2)
     assert_that(modified_timedelta, less_than(max_expected_timedelta))
Ejemplo n.º 46
0
 def test_start_direct_backward_with_initial_opposite_speed_turn_left(self):
     controller = Controller(distance_to_wheels=1)
     result = controller(
         course=Point(-1, -0.1),
         angle=0,
         direct_speed=Point(1, 0),
         angular_speed_angle=0,
         engine_power=0,
         wheel_turn=0,
         target_speed=Point(-1, -0.1),
         tick=0,
         backward=True,
     )
     assert_that(result.engine_power, equal_to(-1))
     assert_that(result.wheel_turn, less_than(0))
     assert_that(result.brake, equal_to(True))
Ejemplo n.º 47
0
 def test_start_left(self):
     controller = Controller(distance_to_wheels=1)
     result = controller(
         course=Point(0, -1),
         angle=0,
         direct_speed=Point(0, 0),
         angular_speed_angle=0,
         engine_power=0,
         wheel_turn=0,
         target_speed=Point(0, -1),
         tick=0,
         backward=False,
     )
     assert_that(result.engine_power, equal_to(1))
     assert_that(result.wheel_turn, less_than(0))
     assert_that(result.brake, equal_to(False))
Ejemplo n.º 48
0
def check_all_midolman_hosts(alive):
    midonet_api = get_midonet_api()
    max_attempts = 20
    counter = 0
    sleep_time = 10
    failed_midolman = None
    for _ in range(max_attempts):
        try:
            for h in midonet_api.get_hosts():
                assert_that(h.is_alive(), is_(alive),
                            'A Midolman %s is alive.' % h.get_id())
            LOG.debug("Midolman agents took %d attempts of %d s to be up." % (counter,
                                                                              sleep_time))
            break
        except AssertionError:
            failed_midolman = h.get_id()
            time.sleep(sleep_time)
            counter += 1
    assert_that(counter, less_than(max_attempts),
                'Timeout checking for Midolman %s liveness' % failed_midolman)
    def test_write_memory_abort_does_not_call_commit_delay(self, t):
        t.child.timeout = 10
        enable(t)

        t.write("copy running-config startup-config")

        t.readln("")
        t.readln("This operation may take a few minutes.")
        t.readln("Management interfaces will not be available during this time.")
        t.readln("")
        t.read("Are you sure you want to save? (y/n) ")
        t.write_raw("n")
        start_time = time()
        t.readln("")
        t.readln("")
        t.readln("Configuration Not Saved!")
        end_time = time()
        t.read("my_switch#")

        assert_that((end_time - start_time), less_than(COMMIT_DELAY))
Ejemplo n.º 50
0
def impl(context):
    observer = context.observer

    hp_events = [x for x in observer.events if e_event_type(x) == "hit points changed"]

    hp_event = hp_events[0]

    attack_events = [x for x in observer.events if e_event_type(x) == "attack hit"]

    if attack_events:
        attack_event = attack_events[0]

        weapon = e_attacker(attack_event).inventory.weapon

        expected_damage = sum(x[0] for x in weapon.weapon_data.damage)
        realised_damage = e_old_hit_points(hp_event) - e_new_hit_points(hp_event)

    else:
        trap_event = [x for x in observer.events if e_event_type(x) == "damage trap triggered"][0]
        expected_damage = 2
        realised_damage = e_damage(trap_event)[0]

    assert_that(realised_damage, is_(less_than(expected_damage)))
Ejemplo n.º 51
0
    def test_sessions_timeout_let_the_next_session_takeover(self):
        with NetmanTestApp() as partial_client:
            client = partial_client(_switch_of_model("brocade"))

            start_time = time.time()

            result = _create_session(client, "i_love_sessions")
            assert_that(time.time() - start_time, is_(less_than(1)))

            first_session_id = result.json()['session_id']

            result = _create_session(client, "i_really_love_sessions")
            assert_that(time.time() - start_time, is_(greater_than(1)))

            second_session_id = result.json()['session_id']

            result = client.post("/switches-sessions/" + first_session_id + "/actions", data='commit')
            assert_that(result.status_code, is_(404), 'Session should have timed out')

            result = client.post("/switches-sessions/" + second_session_id + "/actions", data='commit')
            assert_that(result.status_code, is_(204), result.text)

            result = client.delete("/switches-sessions/" + second_session_id)
            assert_that(result.status_code, is_(204), result.text)
Ejemplo n.º 52
0
def close_to(target, delta):
    minimum = target - delta
    maximum = target + delta
    return all_of(greater_than(minimum),
                  less_than(maximum))
Ejemplo n.º 53
0
def assert_response_valid(response):
    msg = "URL: %s, Response received: %s" % (response.url, unicode(response.data))
    h.assert_that(response.status, h.greater_than_or_equal_to(200), msg)
    h.assert_that(response.status, h.less_than(400), msg)
def test_efficiently_displays_image_cover_when_it_does_not_change(driver):
    album = make_album(images=[make_image("image/jpeg", _load_test_image("big-image.jpg"), Image.FRONT_COVER)])
    page = show_page(album)

    time = timeit.timeit(lambda: page.display(album), number=50)
    assert_that(time, less_than(1), "time to execute render 50 times")
Ejemplo n.º 55
0
    def test_motion_planning(self):
        max_speed = 2
        axis_config = {
            'x': {
                'max_acceleration': 0.5,
                'max_step_acceleration': 1,
                'max_speed': max_speed,
                'bow': 1,
                'bow_step': 7,
                'scale': 7,
                'motor': 0,
                'steps_per_mm': 7
            },
            'y': {
                'max_acceleration': 0.5,
                'max_step_acceleration': 2,
                'max_speed': max_speed,
                'bow': 1,
                'bow_step': 11,
                'scale': 11,
                'motor': 1,
                'steps_per_mm': 11
            },
            'z': {
                'steps_per_mm': 1,
                'max_speed': 10
            },
            'e': {
                'steps_per_mm': 1,
                'max_speed': 1
            }
        }
        queue = PrintQueue(axis_config=axis_config, min_length=20, max_length=21)
        queue.default_target_speed = max_speed
        # add some circle
        queue.add_movement({
            'type': 'move',
            'x': 1,
            'y': 0
            # movement 0
        })
        queue.add_movement({
            'type': 'move',
            'x': 2,
            'y': 0
            # movement 1
        })
        queue.add_movement({
            'type': 'move',
            'x': 3,
            'y': 0
            # movement 2
        })
        queue.add_movement({
            'type': 'move',
            'x': 4,
            'y': 1
            # movement 3
        })
        queue.add_movement({
            'type': 'move',
            'x': 4,
            'y': 2
            # movement 4
        })
        queue.add_movement({
            'type': 'move',
            'x': 4,
            'y': 3
            # movement 5
        })
        queue.add_movement({
            'type': 'move',
            'x': 3,
            'y': 4
            # movement 6
        })
        queue.add_movement({
            'type': 'move',
            'x': 2,
            'y': 4
            # movement 7
        })
        queue.add_movement({
            'type': 'move',
            'x': 0,
            'y': 4
            # movement 8
        })
        queue.add_movement({
            'type': 'move',
            'x': 0,
            'y': 2
            # movement 9
        })
        queue.add_movement({
            'type': 'move',
            'x': 0,
            'y': 1
            # movement 10
        })
        queue.add_movement({
            'type': 'move',
            'x': 1,
            'y': 0
            # movement 11
        })
        queue.add_movement({
            'type': 'move',
            'x': 2,
            'y': 0
            # movement 12
        })
        assert_that(queue.previous_movement, not_none())
        assert_that(queue.planning_list, has_length(12))
        planned_list = queue.planning_list

        assert_that(planned_list[1]['speed']['x'], equal_to(max_speed))
        assert_that(planned_list[0]['speed']['x'], greater_than(0))
        assert_that(planned_list[0]['speed']['x'], less_than(planned_list[1]['speed']['x']))
        assert_that(planned_list[3]['speed']['x'], less_than(planned_list[1]['speed']['x']))
        assert_that(planned_list[3]['speed']['x'], equal_to(planned_list[0]['speed']['x']))
        assert_that(planned_list[3]['speed']['x'], greater_than(0))
        for i in range(0, 3):
            assert_that(planned_list[i]['delta_y'], equal_to(0))
            assert_that(planned_list[i]['speed']['y'], equal_to(0))
            assert_that(planned_list[i]['speed']['x'], greater_than(0))

        try:
            assert_that(planned_list[2]['x_stop'], not (equal_to(True)))
        except KeyError:
            pass  # ok, this is enough - it should just not be true
        assert_that(planned_list[3]['x_stop'], equal_to(True))

        assert_that(planned_list[4]['speed']['y'], equal_to(max_speed))
        assert_that(planned_list[3]['speed']['y'], greater_than(0))
        assert_that(planned_list[3]['speed']['y'], less_than(planned_list[4]['speed']['y']))
        assert_that(planned_list[6]['speed']['y'], less_than(planned_list[4]['speed']['y']))
        assert_that(planned_list[6]['speed']['y'], greater_than(0))
        assert_that(planned_list[6]['speed']['y'], equal_to(planned_list[3]['speed']['y']))
        assert_that(planned_list[3]['delta_x'], equal_to(1))

        for i in range(4, 5):
            assert_that(planned_list[i]['delta_x'], equal_to(0))
            assert_that(planned_list[i]['speed']['x'], equal_to(0))
            assert_that(planned_list[i]['speed']['y'], greater_than(0))

        try:
            assert_that(planned_list[5]['y_stop'], not (equal_to(True)))
        except KeyError:
            pass  # ok, this is enough - it should just not be true
        assert_that(planned_list[6]['y_stop'], equal_to(True))

        assert_that(planned_list[7]['speed']['x'], equal_to(-max_speed))
        assert_that(planned_list[6]['speed']['x'], less_than(0))
        assert_that(planned_list[6]['speed']['x'], greater_than(planned_list[7]['speed']['x']))
        assert_that(planned_list[8]['speed']['x'], greater_than(planned_list[7]['speed']['x']))
        assert_that(planned_list[8]['speed']['x'], less_than(0))
        assert_that(planned_list[8]['delta_x'], equal_to(-2))
        assert_that(planned_list[8]['x_stop'], equal_to(True))

        for i in range(7, 8):
            assert_that(planned_list[i]['delta_y'], equal_to(0))
            assert_that(planned_list[i]['speed']['y'], equal_to(0))

        try:
            assert_that(planned_list[7]['x_stop'], not (equal_to(True)))
        except KeyError:
            pass  # ok, this is enough - it should just not be true
        assert_that(planned_list[8]['x_stop'], equal_to(True))

        for i in range(9, 10):
            assert_that(planned_list[i]['delta_x'], equal_to(0))
            assert_that(planned_list[i]['speed']['x'], equal_to(0))
            assert_that(planned_list[i]['speed']['y'], less_than(0))

        try:
            assert_that(planned_list[10]['y_stop'], not (equal_to(True)))
        except KeyError:
            pass  # ok, this is enough - it should just not be true
        assert_that(planned_list[11]['y_stop'], equal_to(True))

        # ok so far so good - but let's see if this is correctly converted to a motion
        printer = Printer(serial_port="none", reset_pin="X")
        printer.default_speed = 1
        printer.axis = axis_config
        printer._postconfig()

        class DummyMaychine:
            move_list = []

            def move_to(self, move_config):
                self.move_list.append(move_config)

        printer.machine = DummyMaychine()

        # easy to detect
        nr_of_commands = 0
        move_configs = []
        for movement in planned_list:
            nr_of_commands += 1
            step_pos, step_speed_vector = printer._add_movement_calculations(movement)
            assert_that(step_pos['x'], equal_to(movement['x'] * 7))
            assert_that(step_pos['y'], equal_to(movement['y'] * 11))
            assert_that(step_speed_vector['x'], equal_to(int(movement['speed']['x'] * 7)))
            assert_that(step_speed_vector['y'], equal_to(int(movement['speed']['y'] * 11)))
            x_move_config, y_move_config, z_move_config, e_move_config = printer._generate_move_config(movement,
                                                                                                       step_pos,
                                                                                                       step_speed_vector)
            if x_move_config:
                assert_that(x_move_config['motor'], equal_to(0))
                assert_that(x_move_config['acceleration'], equal_to(1))
                assert_that(x_move_config['startBow'], equal_to(7))
                assert_that(x_move_config['target'], equal_to(movement['x'] * 7))
                assert_that(x_move_config['speed'], equal_to(abs(int(movement['speed']['x'] * 7))))

            if y_move_config:
                assert_that(y_move_config['motor'], equal_to(1))
                assert_that(y_move_config['acceleration'], equal_to(2))
                assert_that(y_move_config['startBow'], equal_to(11))
                assert_that(y_move_config['target'], equal_to(movement['y'] * 11))
                assert_that(y_move_config['speed'], equal_to(abs(int(movement['speed']['y'] * 11))))
            # #collect the move configs for later analyisis
            move_configs.append({
                'x': x_move_config,
                'y': y_move_config
            })
            # move a bit just like the real thing
            printer._move(movement, step_pos, x_move_config, y_move_config, z_move_config, e_move_config)

        assert_that(nr_of_commands, equal_to(12))
        assert_that(len(move_configs), equal_to(12))

        for i in range(0, 2):
            assert_that(move_configs[i]['x']['type'], equal_to('way'))
            assert_that(move_configs[i]['y'], equal_to(None))
        assert_that(move_configs[3]['x']['type'], equal_to('stop'))
        for i in range(3, 5):
            assert_that(move_configs[i]['y']['type'], equal_to('way'))
        assert_that(move_configs[5]['y']['type'], equal_to('way'))
        assert_that(move_configs[8]['x']['type'], equal_to('stop'))
        assert_that(move_configs[7]['x']['type'], equal_to('way'))
        for i in range(0, 3):
            assert_that(move_configs[i]['x']['type'], equal_to('way'))
        for i in range(0, 2):
            assert_that(move_configs[i]['y'], none())
        for i in range(3, 5):
            assert_that(move_configs[i]['y']['type'], equal_to('way'))
        assert_that(move_configs[3]['x']['type'], equal_to('stop'))
        for i in range(4, 5):
            assert_that(move_configs[i]['x'], none())
        for i in range(6, 8):
            assert_that(move_configs[i]['x']['type'], equal_to('way'))
        assert_that(move_configs[6]['y']['type'], equal_to('stop'))
        for i in range(7, 8):
            assert_that(move_configs[i]['y'], none())
        for i in range(9, 10):
            assert_that(move_configs[i]['y']['type'], equal_to('way'))
        assert_that(move_configs[8]['x']['type'], equal_to('stop'))
        for i in range(9, 10):
            assert_that(move_configs[i]['x'], none())

        # ok what do we got in our machine move list??
        machine_move_list = printer.machine.move_list

        assert_that(machine_move_list, has_length(12))
        for i in range(0, 2):
            assert_that(machine_move_list[i], has_length(1))
            assert_that(machine_move_list[i][0]['motor'], equal_to(0))
        assert_that(machine_move_list[3], has_length(2))
        for i in range(4, 5):
            assert_that(machine_move_list[i], has_length(1))
            assert_that(machine_move_list[i][0]['motor'], equal_to(1))
        assert_that(machine_move_list[6], has_length(2))
        for i in range(7, 8):
            assert_that(machine_move_list[i], has_length(1))
            assert_that(machine_move_list[i][0]['motor'], equal_to(0))
        for i in range(9, 10):
            assert_that(machine_move_list[i], has_length(1))
            assert_that(machine_move_list[i][0]['motor'], equal_to(1))
        assert_that(machine_move_list[11], has_length(2))

        def compare_move_configs(machine_move_config, x_move_config, y_move_config):
            x_move = None
            y_move = None
            for machine_move in machine_move_config:
                if machine_move['motor'] == 0:
                    assert_that(x_move, equal_to(None))
                    x_move = machine_move
                if machine_move['motor'] == 1:
                    assert_that(y_move, equal_to(None))
                    y_move = machine_move
            if not x_move:
                assert_that(x_move_config, none())
            if not y_move:
                assert_that(y_move_config, none())
            if x_move and y_move:
                ratio = float(x_move['speed']) / float(y_move['speed'])
                assert_that(float(x_move['acceleration']) / float(y_move['acceleration']), close_to(ratio, 0.0001))
                assert_that(float(x_move['startBow']) / float(y_move['startBow']), close_to(ratio, 0.0001))
            assert_that(y_move or x_move, not (equal_to(None)))

        for command_number, machine_command in enumerate(machine_move_list):
            compare_move_configs(machine_command, move_configs[command_number]['x'], move_configs[command_number]['y'])
Ejemplo n.º 56
0
    def test_print_queue_calculations(self):
        default_timeout = 0.1
        max_speed_x = 3
        max_speed_y = 2
        axis_config = {
            'x': {
                'max_acceleration': 0.5,
                'max_speed': max_speed_x,
                'bow': 1,
                'steps_per_mm': 1
            },
            'y': {
                'max_acceleration': 0.5,
                'max_speed': max_speed_y,
                'bow': 1,
                'steps_per_mm': 1
            },
            'z': {
                'steps_per_mm': 1
            },
            'e': {
                'steps_per_mm': 1
            }
        }
        queue = PrintQueue(axis_config=axis_config, min_length=20, max_length=21)
        queue.default_target_speed = 5

        # TODO add a movement to check if it accelerates correctly
        # we do not need any real buffer
        for i in range(6):
            queue.add_movement({
                'type': 'move',
                'x': i + 1,
                'y': i + 1,
                'f': 10
            })
        last_movement = queue.previous_movement
        assert_that(last_movement['speed'], not_none())
        assert_that(last_movement['speed']['x'], not_none())
        assert_that(last_movement['speed']['x'], less_than_or_equal_to(max_speed_x))
        assert_that(last_movement['speed']['y'], not_none())
        assert_that(last_movement['speed']['y'], less_than_or_equal_to(max_speed_y))
        assert_that(last_movement['speed']['x'], close_to(max_speed_y, 0.01))  # becaus we go 1/1 each time
        assert_that(last_movement['speed']['y'], close_to(max_speed_y, 0.01))
        queue.add_movement({
            'type': 'move',
            'x': 7,
            'y': 6
        })
        last_movement = queue.previous_movement
        assert_that(last_movement['speed']['x'], less_than_or_equal_to(max_speed_x))
        assert_that(last_movement['speed']['x'], greater_than(0))
        assert_that(last_movement['speed']['y'], equal_to(0))
        previous_movement = queue.planning_list[-1]
        assert_that(previous_movement['speed']['x'], less_than(max_speed_x))
        assert_that(previous_movement['speed']['y'], less_than(max_speed_y))
        assert_that(previous_movement['y_stop'], equal_to(True))
        # we still go on in x - so in thery we can speed up to desired target speed
        assert_that(last_movement['speed']['x'], greater_than(previous_movement['speed']['x']))
        previous_movement = queue.planning_list[-3]
        assert_that(previous_movement['speed']['x'], close_to(max_speed_y, 0.5))  # becaus we go 1/1 each time
        assert_that(previous_movement['speed']['y'], close_to(max_speed_y, 0.5))
        queue.add_movement({
            'type': 'move',
            'x': 7,
            'y': 7
        })
        last_movement = queue.previous_movement
        assert_that(last_movement['speed']['x'], equal_to(0))
        assert_that(last_movement['speed']['y'], greater_than(0))
        assert_that(last_movement['speed']['y'], less_than(max_speed_y))
        previous_movement = queue.planning_list[-1]
        assert_that(previous_movement['speed']['x'], less_than(max_speed_x))
        assert_that(previous_movement['x_stop'], equal_to(True))
        assert_that(previous_movement['speed']['y'], less_than(max_speed_y))
        assert_that(previous_movement['speed']['y'], equal_to(0))
        previous_movement = queue.planning_list[-4]
        assert_that(previous_movement['speed']['x'], close_to(max_speed_y, 0.5))  # becaus we go 1/1 each time
        assert_that(previous_movement['speed']['y'], close_to(max_speed_y, 0.5))
        # let's go back to zero to begin a new test
        queue.add_movement({
            'type': 'move',
            'x': 0,
            'y': 7
        })
        last_movement = queue.previous_movement
        # it is a long go - so we should be able to speed up to full steam
        assert_that(last_movement['speed']['x'], close_to(-max_speed_x, 0.5))
        assert_that(last_movement['speed']['y'], equal_to(0))
        previous_movement = queue.planning_list[-1]
        assert_that(previous_movement['y_stop'], equal_to(True))
        queue.add_movement({
            'type': 'move',
            'x': 0,
            'y': 0
        })
        last_movement = queue.previous_movement
        # it is a long go - so we should be able to speed up to full steam
        assert_that(last_movement['speed']['x'], equal_to(0))
        assert_that(last_movement['speed']['y'], close_to(-max_speed_y, 0.5))
        previous_movement = queue.planning_list[-1]
        assert_that(previous_movement['x_stop'], equal_to(True))
        # speed up
        for i in range(4):
            queue.add_movement({
                'type': 'move',
                'x': i + 1,
                'y': i + 1,
            })
        last_movement = queue.previous_movement
        assert_that(last_movement['speed']['x'], close_to(max_speed_y, 0.01))  # becaus we go 1/1 each time
        assert_that(last_movement['speed']['y'], close_to(max_speed_y, 0.01))
        # and check if we can do a full stop
        queue.add_movement({
            'type': 'move',
            'x': 3,
            'y': 3
        })
        last_movement = queue.previous_movement
        assert_that(last_movement['speed']['x'], less_than(0))
        assert_that(last_movement['speed']['x'], greater_than(-max_speed_x))
        assert_that(last_movement['speed']['y'], less_than(0))
        assert_that(last_movement['speed']['y'], greater_than(-max_speed_y))
        previous_movement = queue.planning_list[-1]
        assert_that(previous_movement['speed']['x'], less_than(max_speed_x))
        assert_that(previous_movement['speed']['y'], less_than(max_speed_y))
        assert_that(previous_movement['y_stop'], equal_to(True))
        assert_that(previous_movement['x_stop'], equal_to(True))
        another_previous_movement = queue.planning_list[-3]
        assert_that(another_previous_movement['speed']['x'],
                    greater_than(previous_movement['speed']['x']))  # becaus we stopped to turn around
        assert_that(another_previous_movement['speed']['y'], greater_than(previous_movement['speed']['x']))