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
    def test_list(self, user1, user2, user3):
        self.client.external.create('foo', user1['uuid'], self.original_data)
        self.client.external.create('bar', user1['uuid'], self.original_data)
        self.client.external.create('foo', user2['uuid'], self.original_data)

        result = self.client.external.list_(user3['uuid'])
        expected = [
            {'type': 'foo', 'data': {}, 'plugin_info': {}, 'enabled': False},
            {
                'type': 'bar',
                'data': {},
                'plugin_info': {'foo': 'bar'},
                'enabled': False,
            },
        ]
        assert_that(
            result,
            has_entries(
                items=has_items(*expected),
                total=greater_than_or_equal_to(2),
                filtered=greater_than_or_equal_to(2),
            ),
        )

        result = self.client.external.list_(user1['uuid'])
        expected = [
            {'type': 'foo', 'data': {}, 'plugin_info': {}, 'enabled': True},
            {
                'type': 'bar',
                'data': self.safe_data,
                'plugin_info': {'foo': 'bar'},
                'enabled': True,
            },
        ]
        assert_that(
            result,
            has_entries(
                items=has_items(*expected),
                total=greater_than_or_equal_to(2),
                filtered=greater_than_or_equal_to(2),
            ),
        )

        result = self.client.external.list_(user1['uuid'], type='bar')
        expected = [
            {
                'type': 'bar',
                'data': self.safe_data,
                'plugin_info': {'foo': 'bar'},
                'enabled': True,
            }
        ]
        assert_that(
            result,
            has_entries(
                items=contains_exactly(*expected),
                total=greater_than_or_equal_to(2),
                filtered=1,
            ),
        )
Beispiel #3
0
def step_then_the_booking_is_shown_to_be_updated(context):
    json = response.json()

    assert_that(json, has_key('firstname'))
    assert_that(json, has_key('lastname'))
    assert_that(json['firstname'], greater_than_or_equal_to('Matus'))
    assert_that(json['lastname'], greater_than_or_equal_to('Novak'))
    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)))
 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()
Beispiel #6
0
    def test_user_counter_using_pardo(self):
        class SomeDoFn(beam.DoFn):
            """A custom dummy DoFn using yield."""
            static_counter_elements = metrics.Metrics.counter(
                "SomeDoFn", 'metrics_static_counter_element')

            def __init__(self):
                self.user_counter_elements = metrics.Metrics.counter(
                    self.__class__, 'metrics_user_counter_element')

            def process(self, element):
                self.static_counter_elements.inc(2)
                self.user_counter_elements.inc()
                distro = Metrics.distribution(self.__class__, 'element_dist')
                distro.update(element)
                yield element

        pipeline = TestPipeline()
        nums = pipeline | 'Input' >> beam.Create([1, 2, 3, 4])
        results = nums | 'ApplyPardo' >> beam.ParDo(SomeDoFn())
        assert_that(results, equal_to([1, 2, 3, 4]))

        res = pipeline.run()
        res.wait_until_finish()

        # Verify static counter.
        metric_results = (res.metrics().query(MetricsFilter().with_metric(
            SomeDoFn.static_counter_elements)))
        outputs_static_counter = metric_results['counters'][0]

        self.assertEqual(outputs_static_counter.key.metric.name,
                         'metrics_static_counter_element')
        self.assertEqual(outputs_static_counter.committed, 8)

        # Verify user counter.
        metric_results = (res.metrics().query(
            MetricsFilter().with_name('metrics_user_counter_element')))
        outputs_user_counter = metric_results['counters'][0]

        self.assertEqual(outputs_user_counter.key.metric.name,
                         'metrics_user_counter_element')
        self.assertEqual(outputs_user_counter.committed, 4)

        # Verify user distribution counter.
        metric_results = res.metrics().query()
        matcher = MetricResultMatcher(
            step='ApplyPardo',
            namespace=hc.contains_string('SomeDoFn'),
            name='element_dist',
            committed=DistributionMatcher(
                sum_value=hc.greater_than_or_equal_to(0),
                count_value=hc.greater_than_or_equal_to(0),
                min_value=hc.greater_than_or_equal_to(0),
                max_value=hc.greater_than_or_equal_to(0)))
        hc.assert_that(metric_results['distributions'],
                       hc.contains_inanyorder(matcher))
Beispiel #7
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()
 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()
Beispiel #9
0
 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))
Beispiel #10
0
    def test_list_paginating(self, token_2, token_1, *_):
        response = self.client.sessions.list(limit=1)
        assert_that(
            response,
            has_entries(
                total=greater_than_or_equal_to(2),
                filtered=greater_than_or_equal_to(2),
                items=has_length(1),
            ))

        response = self.client.sessions.list(offset=1)
        assert_that(
            response,
            has_entries(total=greater_than_or_equal_to(2),
                        filtered=greater_than_or_equal_to(2),
                        items=has_length(response['total'] - 1)))
Beispiel #11
0
    def get_usage_data(self, host, check=True):
        """Step to get cpu/memory/hdd data for host.

        # usage_data is the list of the following elements:
        # elem 0 - 'total' data, 1 - 'used now' data, 2 - 'used max' data
        # next elements - for VMs (one element per project)
        # Every element consists of project, cpu, memory_mb, disk_gb etc.

        Args:
            host (object): host
            check (bool, optional): flag whether to check step or not

        Raises:
            AssertionError: if usage data has less than 3 elements
        """
        usage_data = self._client.get(host.host_name)

        if check:
            assert_that(len(usage_data), greater_than_or_equal_to(3))
            for data in usage_data:
                for attr in ['project', 'cpu', 'memory_mb', 'disk_gb']:
                    assert_that(hasattr(data, attr))
            assert_that(usage_data[0].project, equal_to('(total)'))
            assert_that(usage_data[1].project, equal_to('(used_now)'))
            assert_that(usage_data[2].project, equal_to('(used_max)'))

        return usage_data
Beispiel #12
0
    def test_list_paginating(self, token_2, token_1, user):
        response = self.client.users.get_sessions(user['uuid'], limit=1)
        assert_that(
            response,
            has_entries(
                total=greater_than_or_equal_to(2),
                filtered=greater_than_or_equal_to(2),
                items=has_length(1),
            ))

        response = self.client.users.get_sessions(user['uuid'], offset=1)
        assert_that(
            response,
            has_entries(total=greater_than_or_equal_to(2),
                        filtered=greater_than_or_equal_to(2),
                        items=has_length(response['total'] - 1)))
Beispiel #13
0
    def _check_time(self, granularity=1.0):
        import time
        for _ in range(10):
            before = time.time()
            after = time.time()
            assert_that(after, is_(greater_than_or_equal_to(before + granularity)))


            assert_that(time.gmtime(after), is_(time.gmtime(after)))
            assert_that(time.gmtime(after), is_(greater_than_or_equal_to(time.gmtime(before))))

            if granularity >= 1.0:
                gm_before = time.gmtime()
                gm_after = time.gmtime()
                assert_that(gm_after, is_(greater_than(gm_before)))
        return after
Beispiel #14
0
 def exists_within_timeout(self, finder, **options):
     try:
         self.wait_find_with_result_matcher(
             finder, has_length(greater_than_or_equal_to(1)), **options)
         return True
     except NotFoundError:
         return False
Beispiel #15
0
def step_given_hotel_has_existing_booking(context):
    global request_body
    request_body = {
        'firstname': 'rose',
        'lastname': 'boylu',
        'totalprice': 20,
        'depositpaid': 'true',
        'bookingdates': {
            'checkin': '2020-07-2',
            'checkout': '2020-07-2',
        },
        'additionalneeds': "no"
    }
    global response
    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': f'Bearer {get_token()}'
    }
    response = requests.post('http://localhost:8080/api/booking',
                             json=request_body,
                             headers=headers)
    assert_that(response.status_code, equal_to(200))

    global last_booking_id
    json = response.json()
    assert_that(json['id'], greater_than_or_equal_to(1))
    last_booking_id = json['id']
Beispiel #16
0
 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])
    def test_del(self, rpc_call):
        rpc_call.return_value = None

        del (self._subject)

        gc.collect()

        assert_that(len(rpc_call.mock_calls), greater_than_or_equal_to(1))
Beispiel #18
0
def _check_machine_listing_contents(context, cmd_output, *, shallow):
    """Checks for expected contents in a machine listing"""
    expected_hostnames = set(context.vm_helper.machines.values())
    listing = json.loads(cmd_output)["machines"]
    # Check number of entries
    assert_that(len(listing),
                greater_than_or_equal_to(len(expected_hostnames)))
    # Check expected hostnames were found
    found_hostnames = set(vm["hostname"] for vm in listing)
    assert_that(found_hostnames, greater_than_or_equal_to(expected_hostnames))
    # Check shallow listing omits package details
    # while full listing includes them
    if shallow:
        for vm in listing:
            assert_that(vm["os"]["packages"], equal_to([]))
    else:
        for vm in listing:
            assert_that(len(vm["os"]["packages"]), greater_than(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)))
Beispiel #20
0
 def exists_within_timeout(self, finder):
     try:
         self.wait_find_with_result_matcher(
             finder,
             has_length(greater_than_or_equal_to(1))
         )
         return True
     except NotFoundError:
         return False
def test_generated_dms_id_should_not_conflict_with_production_ones():
    """Wisdom already generates DMS ids upto 9 digits long and therefore we
    need to generate ids which are longer.
    """
    # when
    dms_id = generate_dms_id()
    # then
    assert_that(type(dms_id), is_(type(str)))
    assert_that(len(dms_id), greater_than_or_equal_to(10))
Beispiel #22
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))
Beispiel #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))
Beispiel #24
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),
    )
Beispiel #25
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)
Beispiel #26
0
def elliptics_result_with(error_code, timestamp, user_flags, data):
    """Matches if elliptics async_result meets the following conditions:
    
      * async_result.error.code == zero
      * async_result.timestamp >= timestamp before this operation
      * async_result.user_flags has proper value

    """
    return has_properties('error', has_property('code', equal_to(error_code)),
                          'timestamp', greater_than_or_equal_to(timestamp),
                          'user_flags', equal_to(user_flags),
                          'data', with_same_sha1_as(data))
Beispiel #27
0
 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])
Beispiel #28
0
 def test_move_left_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_left()
         assert_that(tetris.current_column, equal_to(margin - 1))
         for _ in range(10):
             tetris.move_left()
             assert_that(tetris.current_column, greater_than_or_equal_to(0))
Beispiel #29
0
    def test_some_slow_work(self):
        before = datetime.datetime.now()

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

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

        after = datetime.datetime.now()

        assert_that((after - before).total_seconds(),
                    greater_than_or_equal_to(1.9))
Beispiel #30
0
 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()
Beispiel #31
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))
Beispiel #32
0
 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()
Beispiel #33
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))
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()
Beispiel #35
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)))
Beispiel #36
0
 def test_get_all_by_mover(self):
     mover = VNXMover(mover_id=2, cli=t_nas())
     mps = VNXFsMountPointList(mover=mover, cli=t_nas())
     assert_that(len(mps), greater_than_or_equal_to(1))
Beispiel #37
0
 def test_start_sets_pid(self):
     task = Task(noop)
     task.start()
     assert_that(task.pid, is_(greater_than_or_equal_to(0)))
Beispiel #38
0
 def test_get_all(self):
     cifs_list = VNXCifsServer.get(t_nas())
     assert_that(len(cifs_list), greater_than_or_equal_to(1))
     cifs = next(cifs for cifs in cifs_list if cifs.name == 'CIFS')
     self.verify_pie_cifs(cifs)
Beispiel #39
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()
Beispiel #40
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()
Beispiel #41
0
 def test_get_all(self):
     mps = VNXFsMountPointList(cli=t_nas())
     assert_that(len(mps), greater_than_or_equal_to(1))
     mp = next(mp for mp in mps if mp.path == '/zhuanc_fs_100g')
     self.verify_fs_100g(mp)
 def times(self, n):
     hamcrest.assert_that(
         self.method,
         doublex.called().with_args(*self.args, **self.kargs).times(
             hamcrest.greater_than_or_equal_to(n)))
 def test_track_duration_for(self):
     """ Testing measurement. """
     duration = track_duration_of(lambda: time.sleep(0.25))
     assert_that(duration, greater_than_or_equal_to(0.25))
     duration = track_duration_of(lambda: time.sleep(0.5))
     assert_that(duration, greater_than_or_equal_to(0.5))
Beispiel #44
0
 def test_get_all_by_mover(self):
     mover = VNXMover(mover_id=2, cli=t_nas())
     mps = VNXFsMountPointList(mover=mover, cli=t_nas())
     assert_that(len(mps), greater_than_or_equal_to(1))
Beispiel #45
0
 def test_get_all(self):
     cifs_list = VNXCifsServerList(t_nas())
     assert_that(len(cifs_list), greater_than_or_equal_to(1))
     cifs = next(cifs for cifs in cifs_list if cifs.name == 'CIFS')
     self.verify_pie_cifs(cifs)
Beispiel #46
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))
Beispiel #47
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)))
Beispiel #48
0
def step_impl(context):
    package_list = context.browser.find_element_by_class_name('packages')
    packages = package_list.find_elements_by_xpath("//td/a")
    assert_that(len(packages), greater_than_or_equal_to(1))
    return [dom_element_size(packages[0]),dom_element_size(packages[1])]
Beispiel #49
0
 def test_get_all(self):
     vdm_list = VNXVdm.get(t_nas())
     assert_that(len(vdm_list), greater_than_or_equal_to(1))
     dm = next(dm for dm in vdm_list if dm.vdm_id == 2)
     self.verify_vdm_2(dm)
Beispiel #50
0
 def test_get_all(self):
     vdm_list = VNXVdm.get(t_nas())
     assert_that(len(vdm_list), greater_than_or_equal_to(1))
     dm = next(dm for dm in vdm_list if dm.vdm_id == 2)
     self.verify_vdm_2(dm)
Beispiel #51
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 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)
Beispiel #53
0
def check_fulfilled_capacity(context):
    assert_that(
        context.spot_fleet.fulfilled_capacity,
        greater_than_or_equal_to(context.spot_fleet.target_capacity),
    )
Beispiel #54
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()