コード例 #1
0
def get_driver(browser: str, resolution: str):

    if browser.upper() == "CH":
        driver = webdriver.Chrome(
            executable_path=ChromeDriverManager().install())
    elif browser.upper() == "CH_HL":
        options = webdriver.ChromeOptions()
        options.add_argument("--headless")
        options.add_argument("--no-sandbox")
        options.add_argument("--disable-dev-shm-usage")
        options.add_argument("--disable-setuid-sandbox")
        driver = webdriver.Chrome(
            executable_path=ChromeDriverManager().install(),
            chrome_options=options)
    else:
        raise KeyError(f"Unexpected browser '{browser.upper()}'."
                       f"Check your behave.ini file for available variables")
    if resolution != "1200x800":
        resolution = resolution.split("x")
        screen_width = resolution[0]
        screen_height = resolution[1]
        assert_that(int(screen_width),
                    is_(greater_than_or_equal_to(800)),
                    reason='Width should be greater than 800')
        assert_that(int(screen_width),
                    is_(less_than_or_equal_to(2000)),
                    reason='Width should be lower than 2000')
        assert_that(int(screen_height),
                    is_(greater_than_or_equal_to(600)),
                    reason='Height should be greater than 600')
        assert_that(int(screen_height),
                    is_(less_than_or_equal_to(2000)),
                    reason='Height should be lower than 2000')
        driver.set_window_size(width=screen_width, height=screen_height)
    return driver
コード例 #2
0
    def it_returns_random_point_within_the_given_data_boundaries():
        centroid = ml.random_centroid_in((-15, -3, 20, 10))

        cx = centroid[0]
        cy = centroid[1]
        assert_that(cx, all_of(
            greater_than_or_equal_to(-15), less_than_or_equal_to(20)))
        assert_that(cy, all_of(
            greater_than_or_equal_to(-3), less_than_or_equal_to(10)))
コード例 #3
0
 def check_latlon_subsetting(self, lat_max, lat_min, lon_max, lon_min, lat_var='latitude', lon_var='longitude'):
     self.ds = Dataset(self.OUTPUT_FILENAME)
     lat = self.ds.variables[lat_var][:]
     lon = self.ds.variables[lon_var][:]
     assert_that(min(lon), greater_than_or_equal_to(lon_min))
     assert_that(max(lon), less_than_or_equal_to(lon_max))
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
     self.ds.close()
コード例 #4
0
 def test_credential_error_no_heart_beat(self):
     hb = NodeHeartBeat(interval=0.01)
     hb.add('spa', '1.1.1.1')
     hb.add('spb', '1.1.1.2')
     assert_that(hb.is_available('spa'), equal_to(True))
     assert_that(hb.is_available('spb'), equal_to(True))
     time.sleep(0.1)
     assert_that(hb.command_count, less_than_or_equal_to(2))
     assert_that(hb.command_count, less_than_or_equal_to(2))
     hb.stop()
コード例 #5
0
ファイル: test_heart_beat.py プロジェクト: crook/storops
 def test_credential_error_no_heart_beat(self):
     hb = NodeHeartBeat(interval=0.01)
     hb.add('spa', '1.1.1.1')
     hb.add('spb', '1.1.1.2')
     assert_that(hb.is_available('spa'), equal_to(True))
     assert_that(hb.is_available('spb'), equal_to(True))
     time.sleep(0.1)
     assert_that(hb.command_count, less_than_or_equal_to(2))
     assert_that(hb.command_count, less_than_or_equal_to(2))
     hb.stop()
コード例 #6
0
ファイル: ReSTcont.py プロジェクト: nfredrik/pyjunk
def step_impl(context):
    actual_time = parser.parse(context.time)
    assert_that(
        actual_time,
        less_than_or_equal_to(
            datetime.datetime.now(
                datetime.timezone.utc).replace(microsecond=0)))
コード例 #7
0
 def assert_valid_metadata(self):
     actual_time = parser.parse(self.response.headers['Date'])
     assert_that(
         actual_time,
         less_than_or_equal_to(
             datetime.datetime.now(
                 datetime.timezone.utc).replace(microsecond=0)))
コード例 #8
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()
コード例 #9
0
ファイル: __init__.py プロジェクト: K-Gazdikova/prototype
    def check_response_time(self,
                            cmd_args,
                            time_limit,
                            *,
                            specify_default_user=False,
                            use_default_identity=False,
                            use_default_password=False,
                            as_sudo=False):
        """Check given command completes within the specified time limit

        Returns the contents of stdout as a string.
        """
        start = time.monotonic()
        if use_default_password:
            cmd_output = self._run_leapp_with_askpass(cmd_args)
        else:
            add_default_user = specify_default_user or use_default_identity
            cmd_output = self._run_leapp(
                cmd_args,
                add_default_user=add_default_user,
                add_default_identity=use_default_identity,
                as_sudo=as_sudo)
        response_time = time.monotonic() - start
        assert_that(response_time, less_than_or_equal_to(time_limit))
        return cmd_output
コード例 #10
0
    def check_response_time(self, cmd_args, time_limit, *,
                            specify_default_user=False,
                            as_sudo=False,
                            expect_failure=False):
        """Check given command completes within the specified time limit

        Returns the contents of stdout as a string.
        """
        is_migrate = 'migrate-machine' in cmd_args
        start = time.monotonic()
        add_default_user = specify_default_user
        try:
            cmd_output = self._run_leapp(cmd_args,
                                        add_default_user=add_default_user,
                                        is_migrate=is_migrate,
                                        as_sudo=as_sudo)
        except subprocess.CalledProcessError as exc:
            if not expect_failure:
                raise
            cmd_output = exc.stdout
        else:
            if expect_failure:
                raise AssertionError("Command succeeded unexpectedly")
        response_time = time.monotonic() - start
        assert_that(response_time, less_than_or_equal_to(time_limit))
        return cmd_output
コード例 #11
0
    def check_iperf_loss_context(self,
                                 server_ssh,
                                 ip,
                                 port,
                                 time=60,
                                 max_loss=0):
        """Step to check that iperf loss inside CM is less than max_loss.

        Note:
            This step requires to iperf server will be launched with listening
            for UDP protocol.

        Args:
            server_ssh (obj): instance of stepler.third_party.ssh.SshClient
            ip (str): iperf server ip address
            port (int): iperf server port
            time (int, optional): time to generate traffic
            max_loss (float): maximum allowed datagramm loss in percents

        Raises:
            AssertionError: if iperf loss is greater than `max_loss`
        """
        with iperf.iperf(remote=server_ssh,
                         ip=ip,
                         time=time,
                         port=port,
                         udp=True) as result:
            yield
        assert_that(result['summary']['error_percent'],
                    less_than_or_equal_to(max_loss))
コード例 #12
0
 def check_pres_subsetting(self, pres_max, pres_min, pres_name='air_pressure'):
     import numpy as np
     self.ds = Dataset(self.OUTPUT_FILENAME)
     pres = self.ds.variables[pres_name][:]
     assert_that(np.min(pres), greater_than_or_equal_to(pres_min))
     assert_that(np.max(pres), less_than_or_equal_to(pres_max))
     self.ds.close()
コード例 #13
0
ファイル: base_integration_test.py プロジェクト: cpaulik/cis
 def check_latlon_subsetting(self, lat_max, lat_min, lon_max, lon_min, gridded):
     if gridded:
         lat_name = "lat"
         lon_name = "lon"
         output_path = self.GRIDDED_OUTPUT_FILENAME
     else:
         lat_name = "latitude"
         lon_name = "longitude"
         output_path = self.UNGRIDDED_OUTPUT_FILENAME
     ds = Dataset(output_path)
     lat = ds.variables[lat_name][:]
     lon = ds.variables[lon_name][:]
     assert_that(min(lon), greater_than_or_equal_to(lon_min))
     assert_that(max(lon), less_than_or_equal_to(lon_max))
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
コード例 #14
0
 def does_not_exist_within_timeout(self, finder, **options):
     try:
         self.wait_find_with_result_matcher(
             finder, has_length(less_than_or_equal_to(0)), **options)
         return True
     except NotFoundError:
         return False
コード例 #15
0
ファイル: test_subset.py プロジェクト: gitter-badger/cis-1
 def test_GIVEN_multiple_gridded_variables_on_different_grids_WHEN_subset_THEN_subset_correctly(self):
     variable1 = 'v_1'
     variable2 = 'rh'
     filename = valid_1d_filename
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable1 + ',' + variable2 + ':' + filename,
                  'y=[%s,%s]' % (lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.ds = Dataset(self.OUTPUT_FILENAME)
     lat = self.ds.variables['latitude'][:]
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
     lat_1 = self.ds.variables['latitude_1'][:]
     assert_that(min(lat_1), greater_than_or_equal_to(lat_min))
     assert_that(max(lat_1), less_than_or_equal_to(lat_max))
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable1, variable2])
コード例 #16
0
    def test_search_performance(self):
        with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
            number_of_threads = 10
            futures = [executor.submit(self.measure_search) for i in range(number_of_threads)]
            response_times = [completed.result()["response time"] for completed in as_completed(futures)]
            hit_numbers = [completed.result()["number of hits"] for completed in as_completed(futures)]

        assert_that(hit_numbers, only_contains(greater_than_or_equal_to(5)))
        assert_that(response_times, only_contains(less_than_or_equal_to(1000)))
コード例 #17
0
ファイル: core.py プロジェクト: manicphase/Geist
 def does_not_exist_within_timeout(self, finder):
     try:
         self.wait_find_with_result_matcher(
             finder,
             has_length(less_than_or_equal_to(0))
         )
         return True
     except NotFoundError:
         return False
コード例 #18
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),
    )
コード例 #19
0
    def check_response_time(self, cmd_args, time_limit):
        """Check given command completes within the specified time limit

        Returns the contents of stdout as a string.
        """
        start = time.monotonic()
        cmd_output = self._run_leapp(*cmd_args)
        response_time = time.monotonic() - start
        assert_that(response_time, less_than_or_equal_to(time_limit))
        return cmd_output
コード例 #20
0
def step_impl(context, cid):
    redis = CloudRedis()
    link = eval(redis.get_link_by_cid(cid))
    logger.info("cid %s link route is %s" % (cid, link))
    assert link is not None
    assert_that(link, starts_with('link'), "link route is %s" % link)
    assert_that(len(link), less_than_or_equal_to(6),
                "link route is %s and length > 6" % link)
    assert_that(len(link), greater_than_or_equal_to(5),
                "link route is %s and length < 5" % link)
    time.sleep(1)
コード例 #21
0
ファイル: test_subset.py プロジェクト: cpaulik/cis
 def test_GIVEN_multiple_gridded_variables_on_different_grids_WHEN_subset_THEN_subset_correctly(self):
     variable1 = "v_1"
     variable2 = "rh"
     filename = valid_1d_filename
     lat_min, lat_max = 40, 60
     arguments = [
         "subset",
         variable1 + "," + variable2 + ":" + filename,
         "y=[%s,%s]" % (lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     ds = Dataset(self.GRIDDED_OUTPUT_FILENAME)
     lat = ds.variables["latitude"][:]
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
     lat_1 = ds.variables["latitude_1"][:]
     assert_that(min(lat_1), greater_than_or_equal_to(lat_min))
     assert_that(max(lat_1), less_than_or_equal_to(lat_max))
     self.check_output_contains_variables(self.GRIDDED_OUTPUT_FILENAME, [variable1, variable2])
コード例 #22
0
    def test_shuffle(self):
        """ Testing shuffle of elements. """

        values = []
        for pos in range(100):
            results = select(1, 10, 1).shuffled()
            exact_positions = 0
            for index, value in enumerate(results):
                if index + 1 == value:
                    exact_positions += 1
            values.append(exact_positions)
        average = sum(values) / float(len(values))
        assert_that(average, less_than_or_equal_to(2.0))
コード例 #23
0
ファイル: test_tetris.py プロジェクト: Nachtfeuer/concept-py
 def test_move_right_simple(self):
     """Testing Tetris.move_left method."""
     with mock.patch.object(Tetris, "get_next_shape") as mocked_method:
         shape = Raster.create_from(Tetris.SHAPES[0])
         mocked_method.return_value = shape
         tetris = Tetris(6, 10)
         margin = (tetris.raster.width - shape.width) // 2
         assert_that(tetris.current_column, equal_to(margin))
         tetris.move_right()
         assert_that(tetris.current_column, equal_to(margin + 1))
         expected = tetris.raster.width - tetris.shape.width
         for _ in range(10):
             tetris.move_right()
             assert_that(tetris.current_column, less_than_or_equal_to(expected))
コード例 #24
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_or_equal_to(float(report.get('stop'))))))

    assert_that(
        report.get('stop'),
        has_float(
            all_of(
                greater_than(float(report.get('start'))),
                less_than_or_equal_to(stop * 1000),
            )))
コード例 #25
0
    def test_some_fast_work(self):
        before = datetime.datetime.now()

        futures = []
        for i in range(0, 20):
            futures += [self._subject.submit(short_sleep)]

        for future in as_completed(futures):
            _ = future.result()

        after = datetime.datetime.now()

        assert_that((after - before).total_seconds(),
                    less_than_or_equal_to(0.3))
コード例 #26
0
ファイル: test_heart_beat.py プロジェクト: crook/storops
 def test_interval_change(self):
     hb = NodeHeartBeat(interval=0.1)
     hb.add('spa', '1.1.1.1')
     hb.add('spb', '1.1.1.2')
     time.sleep(0.5)
     hb.interval = 2
     time.sleep(1)
     # total call count is calculated like this:
     #   interval = 0.1, duration = 0.5, 5 >= cycle >= 4
     #   interval = 2, duration = 1, 0 <= cycle <= 1
     #   4 <= total cycle <= 6
     # each cycle has 2 call (one for each SP)
     # 8 <= total call count <= 12
     assert_that(hb.command_count, less_than_or_equal_to(12))
     assert_that(hb.command_count, greater_than_or_equal_to(8))
     hb.stop()
コード例 #27
0
ファイル: test_heart_beat.py プロジェクト: optionalg/storops
 def test_interval_change(self):
     hb = NodeHeartBeat(interval=0.1)
     hb.add('spa', '1.1.1.1')
     hb.add('spb', '1.1.1.2')
     time.sleep(0.5)
     hb.interval = 2
     time.sleep(1)
     # total call count is calculated like this:
     #   interval = 0.1, duration = 0.5, 5 >= cycle >= 4
     #   interval = 2, duration = 1, 0 <= cycle <= 1
     #   4 <= total cycle <= 6
     # each cycle has 2 call (one for each SP)
     # 8 <= total call count <= 12
     assert_that(hb.command_count, less_than_or_equal_to(12))
     assert_that(hb.command_count, greater_than_or_equal_to(8))
     hb.stop()
コード例 #28
0
    def check_ping_loss_context(self, ip_to_ping, max_loss=0, server_ssh=None):
        """Step to check that ping losses inside CM is less than max_loss.

        Args:
            ip_to_ping (str): ip address to ping
            max_loss (int): maximum allowed pings loss
            server_ssh (obj, optional): instance of
                stepler.third_party.ssh.SshClient. If None - ping will be run
                from local machine

        Raises:
            AssertionError: if ping loss is greater than `max_loss`
        """
        with ping.Pinger(ip_to_ping, remote=server_ssh) as result:
            yield
        assert_that(result.loss, less_than_or_equal_to(max_loss))
コード例 #29
0
 def check_temporal_subsetting(self, t_min, t_max):
     import datetime
     self.ds = Dataset(self.OUTPUT_FILENAME)
     cis_standard = datetime.datetime(1600, 1, 1, 0, 0, 0)
     time = self.ds.variables['time']
     datetime_min = datetime.datetime.strptime(t_min, "%Y-%m-%dT%H:%M:%S")
     datetime_max = datetime.datetime.strptime(t_max, "%Y-%m-%dT%H:%M:%S")
     # Expand the search by a second either way to avoid rounding problems
     datetime_min -= datetime.timedelta(seconds=1.5)
     datetime_max += datetime.timedelta(seconds=1.5)
     time_vals = convert_time_since_to_std_time(time[:], time.units)
     for time_val in time_vals:
         delta = datetime.timedelta(days=time_val)
         datetime_value = cis_standard + delta
         assert_that(datetime_value, greater_than_or_equal_to(datetime_min))
         assert_that(datetime_value, less_than_or_equal_to(datetime_max))
コード例 #30
0
ファイル: test_subset.py プロジェクト: gitter-badger/cis-1
 def check_temporal_subsetting(self, t_min, t_max):
     import datetime
     self.ds = Dataset(self.OUTPUT_FILENAME)
     cis_standard = datetime.datetime(1600, 1, 1, 0, 0, 0)
     time = self.ds.variables['time']
     datetime_min = datetime.datetime.strptime(t_min, "%Y-%m-%dT%H:%M:%S")
     datetime_max = datetime.datetime.strptime(t_max, "%Y-%m-%dT%H:%M:%S")
     # Expand the search by a second either way to avoid rounding problems
     datetime_min -= datetime.timedelta(seconds=1.5)
     datetime_max += datetime.timedelta(seconds=1.5)
     time_vals = convert_time_since_to_std_time(time[:], time.units)
     for time_val in time_vals:
         delta = datetime.timedelta(days=time_val)
         datetime_value = cis_standard + delta
         assert_that(datetime_value, greater_than_or_equal_to(datetime_min))
         assert_that(datetime_value, less_than_or_equal_to(datetime_max))
コード例 #31
0
def test_cancels():
    proceed = Event()
    count = 1000
    running_count = 0
    canceled_count = 0
    exception_count = 0
    completed_count = 0

    futures = []

    executor = Executors.thread_pool(max_workers=2).with_cancel_on_shutdown()
    futures = [executor.submit(proceed.wait) for _ in range(0, count)]

    # I'm using wait=False here since otherwise it could block on the 2 threads
    # currently in progress to finish their work items.  I can't see a way to
    # make the test fully synchronized, and using wait=True, without deadlock.
    executor.shutdown(wait=False)

    # Now let those two threads complete (if they've started)
    proceed.set()

    # Collect status of the futures.
    for future in futures:
        if future.running():
            running_count += 1
        elif future.cancelled():
            canceled_count += 1
        elif future.exception():
            exception_count += 1
        elif future.done():
            completed_count += 1

    # No futures should have failed
    assert_that(exception_count, equal_to(0))

    # Could have been anywhere from 0..2 futures running
    assert_that(running_count, is_in((0, 1, 2)))

    # Could have been anywhere from 0..2 futures completed
    assert_that(completed_count, is_in((0, 1, 2)))

    # All others should have been cancelled
    assert_that(canceled_count, less_than_or_equal_to(count))
    assert_that(canceled_count, greater_than_or_equal_to(count - 2))

    # Harmless to call shutdown again
    executor.shutdown()
    def test_some_fast_work(self):
        work = MagicMock()
        work.side_effect = short_sleep()

        before = datetime.datetime.now()

        for i in range(0, 20):
            self._subject.submit(work)

        while len(work.mock_calls) < 20:
            time.sleep(0.01)

        after = datetime.datetime.now()

        assert_that(work.mock_calls, equal_to([call()] * 20))

        assert_that((after - before).total_seconds(),
                    less_than_or_equal_to(0.2))
コード例 #33
0
ファイル: test_minmax.py プロジェクト: NextThought/nti.zodb
    def test_comparisons(self):
        mc1 = self._makeOne()
        mc2 = self._makeOne()

        assert_that(mc1, is_(mc2))

        try:
            mc2.increment()
        except NotImplementedError:
            self.skipTest("Does not support incrementing.")

        assert_that(mc1, is_(less_than(mc2)))
        assert_that(mc2, is_(greater_than(mc1)))

        mc1.increment()
        assert_that(mc1, is_(less_than_or_equal_to(mc2)))

        assert_that(hash(mc1), is_(mc1.value))
コード例 #34
0
def test_throttle(block):
    THREADS = 8
    COUNT = 3
    samples = []
    running_now = []
    lock = Lock()

    def record(x):
        with lock:
            running_now.append(x)

        samples.append(running_now[:])

        # Need to ensure the function takes some time to run
        # so the futures don't complete as fast as we submit them
        time.sleep(0.001)

        with lock:
            running_now.remove(x)

    futures = []
    executor = ThrottleExecutor(Executors.thread_pool(max_workers=THREADS),
                                count=COUNT,
                                block=block)
    with executor:
        for i in range(0, 1000):
            future = executor.submit(record, i)
            futures.append(future)

        # They should all be able to complete
        for future in futures:
            future.result(30.0)

    # Now have a look at running counts
    max_len = 0
    for i, sample in enumerate(samples):
        # There should never have been more futures running than the limit
        sample_len = len(sample)
        assert_that(sample_len, less_than_or_equal_to(COUNT),
                    "failed at step %s" % i)
        max_len = max(max_len, sample_len)

    # It should have been able to run up to the limit too
    assert_that(max_len, equal_to(COUNT))
コード例 #35
0
    def check_arping_loss_context(self,
                                  server_ssh,
                                  ip,
                                  iface='eth0',
                                  max_loss=0):
        """Step to check that arping losses inside CM is less than max_loss.

        Args:
            server_ssh (obj, optional): instance of
                stepler.third_party.ssh.SshClient
            ip (str): ip address to ping
            iface (str, optional): name of interface to arping
            max_loss (int): maximum allowed pings loss

        Raises:
            AssertionError: if ping loss is greater than `max_loss`
        """
        with arping.arping(ip, iface=iface, remote=server_ssh) as result:
            yield
        assert_that(result['sent'] - result['received'],
                    less_than_or_equal_to(max_loss))
コード例 #36
0
def step_impl(context, message, url):
    if message.startswith('Repeat'):
        repeat_cmd, message = message.split(': ', 1)
        repeat_times = int(repeat_cmd[-1])
        message *= repeat_times

    if url == 'None':
        url = None
    else:
        if len(' '.join((message, url))) >= 140:
            message = message[:136 - len(url)] + '... %s' % url
        else:
            message += ' %s' % url

    truncated = BaseStream.truncate_message(None, message, url)
    assert_that(len(truncated), less_than_or_equal_to(140))
    if url is None and len(truncated) == 140:
        assert_that(truncated[-3:], equal_to('...'),
                    'Message was truncated but ellipses are missing.')
        assert_that(truncated[:-3], equal_to(message[:137]))
    else:
        assert_that(truncated, equal_to(message))
コード例 #37
0
ファイル: test_subset.py プロジェクト: cedadev/cis
 def check_aux_subsetting(self, aux_min, aux_max, var):
     self.ds = Dataset(self.OUTPUT_FILENAME)
     alt = self.ds.variables[var][:]
     assert_that(alt.min(), greater_than_or_equal_to(aux_min))
     assert_that(alt.max(), less_than_or_equal_to(aux_max))
     self.ds.close()
コード例 #38
0
 def check_alt_subsetting(self, alt_max, alt_min):
     self.ds = Dataset(self.OUTPUT_FILENAME)
     alt = self.ds.variables['altitude'][:]
     assert_that(min(alt), greater_than_or_equal_to(alt_min))
     assert_that(max(alt), less_than_or_equal_to(alt_max))
     self.ds.close()
コード例 #39
0
 def check_aux_subsetting(self, aux_min, aux_max, var):
     self.ds = Dataset(self.OUTPUT_FILENAME)
     alt = self.ds.variables[var][:]
     assert_that(alt.min(), greater_than_or_equal_to(aux_min))
     assert_that(alt.max(), less_than_or_equal_to(aux_max))
     self.ds.close()
コード例 #40
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']))
コード例 #41
0
def step_impl(context, low, high):
    cap = cv2.VideoCapture(context.output_file_path)
    length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    cap.release()
    assert_that(length, greater_than_or_equal_to(int(low)),
                less_than_or_equal_to(int(high)))
コード例 #42
0
def step_impl(context, low, high):
    media_info = MediaInfo.parse(context.output_file_path)
    duration_in_seconds = int(media_info.tracks[0].duration * 1000)
    assert_that(duration_in_seconds, greater_than_or_equal_to(int(low)),
                less_than_or_equal_to(high))