예제 #1
0
 def test_constraints(self, ports):
     a, b = ports
     self.expectThat(a, GreaterThan(0))
     self.expectThat(a, LessThan(65536))
     self.expectThat(b, GreaterThan(0))
     self.expectThat(b, LessThan(65536))
     self.expectThat(a, Not(Equals(b)))
예제 #2
0
    def test_build_environment_can_depend_on_part_env(self):
        self.useFixture(FakeOsRelease())

        snapcraft_yaml = dedent("""\
            name: test
            base: core18
            version: "1"
            summary: test
            description: test
            confinement: strict
            grade: stable

            parts:
              part1:
                plugin: nil
                build-environment:
                  - PART_INSTALL: $SNAPCRAFT_PART_INSTALL
        """)
        project_config = self.make_snapcraft_project(snapcraft_yaml)
        part = project_config.parts.get_part("part1")
        environment = project_config.parts.build_env_for_part(part)
        snapcraft_definition_index = -1
        build_environment_definition_index = -1
        for index, variable in enumerate(environment):
            if variable.startswith("SNAPCRAFT_PART_INSTALL="):
                snapcraft_definition_index = index
            if variable.startswith("PART_INSTALL="):
                build_environment_definition_index = index

        # Assert that each definition was found, and the part env came before the
        # build environment
        self.assertThat(snapcraft_definition_index, GreaterThan(-1))
        self.assertThat(build_environment_definition_index, GreaterThan(-1))
        self.assertThat(build_environment_definition_index,
                        GreaterThan(snapcraft_definition_index))
예제 #3
0
class TestGreaterThanInterface(TestCase, TestMatchersInterface):

    matches_matcher = GreaterThan(4)
    matches_matches = [5, 8]
    matches_mismatches = [-2, 0, 4]

    str_examples = [
        ("GreaterThan(12)", GreaterThan(12)),
    ]

    describe_examples = [
        ('5 is not < 4', 4, GreaterThan(5)),
        ('4 is not < 4', 4, GreaterThan(4)),
    ]
    def test_window_geometry(self):
        """Window.geometry property

        Check that all Window geometry properties work and have a plausible
        range.
        """
        # ensure we have at least one open app window
        self.start_mock_app(EmulatorBase)

        display = Display.create()
        top = left = right = bottom = None
        # for multi-monitor setups, make sure we examine the full desktop
        # space:
        for monitor in range(display.get_num_screens()):
            sx, sy, swidth, sheight = Display.create().get_screen_geometry(
                monitor
            )
            logger.info(
                "Monitor %d geometry is (%d, %d, %d, %d)",
                monitor,
                sx,
                sy,
                swidth,
                sheight,
            )
            if left is None or sx < left:
                left = sx
            if top is None or sy < top:
                top = sy
            if right is None or sx + swidth >= right:
                right = sx + swidth
            if bottom is None or sy + sheight >= bottom:
                bottom = sy + sheight

        logger.info(
            "Total desktop geometry is (%d, %d), (%d, %d)",
            left,
            top,
            right,
            bottom,
        )
        for win in self.process_manager.get_open_windows():
            logger.info("Win '%r' geometry is %r", win, win.geometry)
            geom = win.geometry
            self.assertThat(len(geom), Equals(4))
            self.assertThat(geom[0], GreaterThan(left - 1))  # no GreaterEquals
            self.assertThat(geom[1], GreaterThan(top - 1))
            self.assertThat(geom[2], LessThan(right))
            self.assertThat(geom[3], LessThan(bottom))
    def _click_overlay(self):
        popup_controller = self.get_popup_controller()
        new_view_watcher = popup_controller.watch_signal(
            'newViewCreated(QString)')
        animation_watcher = popup_controller.watch_signal(
            'windowOverlayOpenAnimationDone()')
        animation_signal_emission = animation_watcher.num_emissions

        views = self.get_popup_overlay_views()
        self.assertThat(len(views), Equals(0))

        self._click_href_target_blank()

        self.assertThat(lambda: new_view_watcher.was_emitted,
                        Eventually(Equals(True)))
        self.assertThat(lambda: len(self.get_popup_overlay_views()),
                        Eventually(Equals(1)))
        views = self.get_popup_overlay_views()
        overlay = views[0]
        self.assertThat(
            overlay.select_single(objectName="overlayWebview").url,
            Contains('/open-close-content'))

        self.assertThat(lambda: animation_watcher.num_emissions,
                        Eventually(GreaterThan(animation_signal_emission)))
예제 #6
0
    def test_pressing_prev_after_5_seconds(self):
        """Pressing previous after 5s jumps to the start of current song"""

        self.app.populate_queue()  # populate queue

        now_playing_page = self.app.get_now_playing_page()

        self.player.isPlaying.wait_for(True)  # ensure the track is playing

        # wait until > 5s
        self.player.position.wait_for(GreaterThan(5000))

        now_playing_page.click_play_button()  # pause the track
        self.player.isPlaying.wait_for(False)  # ensure the track has paused

        source = self.player.currentMeta.filename  # store current source

        now_playing_page.click_previous_button()  # click previous

        # resume the track (to ensure position updates)
        now_playing_page.click_play_button()

        # wait until < 5s
        self.player.position.wait_for(LessThan(5000))

        # Check that the source is the same
        self.assertThat(self.player.currentMeta.filename,
                        Eventually(Equals(source)))
    def test_max_overlay_count_reached(self):
        args = []
        self.launch_webcontainer_app_with_local_http_server(
            args, '/open-close-content',
            {'WEBAPP_CONTAINER_BLOCK_OPEN_URL_EXTERNALLY': '1'})
        self.get_webcontainer_window().visible.wait_for(True)

        popup_controller = self.get_popup_controller()
        webview = self.get_oxide_webview()
        self.assertThat(lambda: webview.visible, Eventually(Equals(True)))

        animation_watcher = popup_controller.watch_signal(
            'windowOverlayOpenAnimationDone()')
        animation_signal_emission = animation_watcher.num_emissions

        OVERLAY_MAX_COUNT = 3
        for i in range(0, OVERLAY_MAX_COUNT):
            self.click_href_target_blank()
            self.assertThat(lambda: animation_watcher.num_emissions,
                            Eventually(GreaterThan(animation_signal_emission)))
            animation_signal_emission = animation_watcher.num_emissions

        external_open_watcher = popup_controller.watch_signal(
            'openExternalUrlTriggered(QString)')

        self.click_href_target_blank()

        self.assertThat(lambda: external_open_watcher.was_emitted,
                        Eventually(Equals(True)))
예제 #8
0
    def test_find_query(self):
        """Creates a story, then does a find to see if it can be located by a partial name from a separate
           connection instance.
        """
        searchName = ""
        exceptionReached = False
        with PublicTestServerConnection.getV1Meta() as v1create:
            createdStory = self._create_story(v1create)

            # make a search term that's just one character shorter
            searchName = createdStory.Name[:-1]
            self.addDetail('search-name', text_content(searchName))

        with PublicTestServerConnection.getV1Meta() as v1find:
            findItems = None
            findItem = None
            size = 0
            firstName = ""
            try:
                findItems = v1find.Story.select('Name').find(text=searchName,
                                                             field='Name')
                findItem = findItems.first()  #actually run the query
                size = len(findItems)
                firstName = findItem.Name
            except Exception as e:
                raise e
                #exceptions here are almost always because the query failed to work right
                exceptionReached = True
            else:
                # at the very least we should have found the one we based the search string on
                self.assertThat(size, GreaterThan(0))
                # results need to contain the string we searched for
                self.assertThat(firstName, Contains(searchName))

            self.assertFalse(exceptionReached)
예제 #9
0
    def test_shopping_scope_preview_navigate_right(self):
        """This test shows that shopping scope results can open previews,
        then move to the next shopping result.
        """
        self.unity.dash.ensure_visible()
        scope = self.unity.dash.get_current_scope()

        self.keyboard.type("playstation")
        results_category = scope.get_category_by_name(_("More suggestions"))

        refresh_results_fn = lambda: len(results_category.get_results())
        self.assertThat(refresh_results_fn,
                        Eventually(GreaterThan(2), timeout=25))

        results = results_category.get_results()
        results[0].preview()

        self.assertThat(self.unity.dash.preview_displaying,
                        Eventually(Equals(True)))
        self.preview_container = self.unity.dash.view.get_preview_container()
        start_index = self.preview_container.relative_nav_index
        self.preview_container.navigate_right()

        self.assertThat(self.preview_container.relative_nav_index,
                        Eventually(Equals(start_index + 1)))
예제 #10
0
def matches_time_or_just_before(time, tolerance=timedelta(seconds=10)):
    """
    Match a time to be equal to a certain time or just before it. Useful when
    checking for a time that is now +/- some amount of time.
    """
    return MatchesAll(GreaterThan(time - tolerance),
                      MatchesAny(LessThan(time), Equals(time)))
예제 #11
0
 def test_launcher_switcher_cycling_backward(self):
     """Launcher Switcher must loop through icons when cycling backwards"""
     self.start_switcher_with_cleanup_cancel()
     self.launcher_instance.switcher_prev()
     # FIXME We can't directly check for self.unity.launcher.num_launcher_icons - 1
     self.assertThat(self.unity.launcher.key_nav_selection,
                     Eventually(GreaterThan(1)))
예제 #12
0
    def test_automatic_retries(self):
        hook = self.factory.makeWebhook()
        job = WebhookDeliveryJob.create(hook, 'test', payload={'foo': 'bar'})
        client = MockWebhookClient(response_status=503)
        self.useFixture(ZopeUtilityFixture(client, IWebhookClient))

        # The first attempt fails but schedules a retry five minutes later.
        self.assertEqual(False, self.runJob(job))
        self.assertEqual(JobStatus.WAITING, job.status)
        self.assertEqual(False, job.successful)
        self.assertTrue(job.pending)
        self.assertIsNot(None, job.date_sent)
        last_date_sent = job.date_sent

        # Pretend we're five minutes in the future and try again. The
        # job will be retried again.
        job.json_data['date_first_sent'] = (
            job.date_first_sent - timedelta(minutes=5)).isoformat()
        job.scheduled_start -= timedelta(minutes=5)
        self.assertEqual(False, self.runJob(job))
        self.assertEqual(JobStatus.WAITING, job.status)
        self.assertEqual(False, job.successful)
        self.assertTrue(job.pending)
        self.assertThat(job.date_sent, GreaterThan(last_date_sent))

        # If the job was first tried a day ago, the next attempt gives up.
        job.json_data['date_first_sent'] = (
            job.date_first_sent - timedelta(hours=24)).isoformat()
        job.scheduled_start -= timedelta(hours=24)
        self.assertEqual(False, self.runJob(job))
        self.assertEqual(JobStatus.FAILED, job.status)
        self.assertEqual(False, job.successful)
        self.assertFalse(job.pending)
예제 #13
0
    def test_scheduled_start(self):
        # Submit four jobs: one in the past, one in the far future, one
        # in 10 seconds, and one at any time.  Wait up to a minute and
        # ensure that the correct three have completed, and that they
        # completed in the expected order.
        self.useFixture(
            FeatureFixture({'jobs.celery.enabled_classes': 'TestJob'}))
        now = datetime.now(UTC)
        job_past = TestJob(scheduled_start=now - timedelta(seconds=60))
        job_past.celeryRunOnCommit()
        self.assertTrue(job_past.is_runnable)
        job_forever = TestJob(scheduled_start=now + timedelta(seconds=600))
        job_forever.celeryRunOnCommit()
        self.assertFalse(job_forever.is_runnable)
        job_future = TestJob(scheduled_start=now + timedelta(seconds=10))
        job_future.celeryRunOnCommit()
        self.assertFalse(job_future.is_runnable)
        job_whenever = TestJob(scheduled_start=None)
        job_whenever.celeryRunOnCommit()
        self.assertTrue(job_whenever.is_runnable)
        transaction.commit()

        count = 0
        while (count < 300 and (job_past.is_pending or job_future.is_pending
                                or job_whenever.is_pending)):
            sleep(0.2)
            count += 1
            transaction.abort()

        self.assertEqual(JobStatus.COMPLETED, job_past.status)
        self.assertEqual(JobStatus.COMPLETED, job_future.status)
        self.assertEqual(JobStatus.COMPLETED, job_whenever.status)
        self.assertEqual(JobStatus.WAITING, job_forever.status)
        self.assertThat(job_future.date_started,
                        GreaterThan(job_past.date_started))
예제 #14
0
    def test_autoscrolling_from_bottom(self):
        """Tests the autoscrolling from the bottom of the Launcher"""
        self.open_apps_in_launcher()

        # Set the autoscroll_offset to 10 (this is arbitrary for this test).
        autoscroll_offset = 10

        launcher_instance = self.get_launcher()
        (x, y, w, h) = launcher_instance.geometry

        icons = self.unity.launcher.model.get_launcher_icons_for_monitor(
            self.launcher_monitor)
        num_icons = self.unity.launcher.model.num_launcher_icons()

        last_icon = icons[num_icons - 1]

        # Move mouse to the middle of the Launcher in order to expand all
        # of the icons for scrolling
        launcher_instance.move_mouse_over_launcher()

        # Make sure the last icon is off the screen or else there is no
        # scrolling.
        self.assertThat(last_icon.center.y, GreaterThan(h))

        # Autoscroll to the last icon
        launcher_instance.move_mouse_to_icon(last_icon, autoscroll_offset)

        (x_fin, y_fin) = self.mouse.position()

        # Make sure we ended up in the center of the last icon
        self.assertThat(x_fin, Equals(last_icon.center.x))
        self.assertThat(y_fin, Equals(last_icon.center.y))
예제 #15
0
    def test_updateStatus_BUILDING_sets_date_started(self):
        # updateStatus sets date_started on transition to BUILDING.
        # date_first_dispatched is also set if it isn't already.
        self.assertEqual(BuildStatus.NEEDSBUILD, self.build_farm_job.status)
        self.assertIs(None, self.build_farm_job.date_started)
        self.assertIs(None, self.build_farm_job.date_first_dispatched)

        self.build_farm_job.updateStatus(BuildStatus.CANCELLED)
        self.assertIs(None, self.build_farm_job.date_started)
        self.assertIs(None, self.build_farm_job.date_first_dispatched)

        # Setting it to BUILDING for the first time sets date_started
        # and date_first_dispatched.
        self.build_farm_job.updateStatus(BuildStatus.NEEDSBUILD)
        self.build_farm_job.updateStatus(BuildStatus.BUILDING)
        self.assertIsNot(None, self.build_farm_job.date_started)
        first = self.build_farm_job.date_started
        self.assertEqual(first, self.build_farm_job.date_first_dispatched)

        self.build_farm_job.updateStatus(BuildStatus.FAILEDTOBUILD)
        with admin_logged_in():
            self.build_farm_job.retry()
        self.assertIs(None, self.build_farm_job.date_started)
        self.assertEqual(first, self.build_farm_job.date_first_dispatched)

        # But BUILDING a second time doesn't change
        # date_first_dispatched.
        self.build_farm_job.updateStatus(BuildStatus.BUILDING)
        self.assertThat(self.build_farm_job.date_started, GreaterThan(first))
        self.assertEqual(first, self.build_farm_job.date_first_dispatched)
예제 #16
0
    def test__returns_at_most_60kiB_of_JSON(self):
        # Configure the rack controller subnet to be very large so it
        # can hold that many BMC connected to the interface for the rack
        # controller.
        rack = factory.make_RackController(power_type='')
        rack_interface = rack.get_boot_interface()
        subnet = factory.make_Subnet(
            cidr=str(factory.make_ipv6_network(slash=8)))
        factory.make_StaticIPAddress(ip=factory.pick_ip_in_Subnet(subnet),
                                     subnet=subnet,
                                     interface=rack_interface)

        # Ensure that there are at least 64kiB of power parameters (when
        # converted to JSON) in the database.
        example_parameters = {"key%d" % i: "value%d" % i for i in range(250)}
        remaining = 2**16
        while remaining > 0:
            node = self.make_Node(bmc_connected_to=rack,
                                  power_parameters=example_parameters)
            remaining -= len(json.dumps(node.get_effective_power_parameters()))

        nodes = list_cluster_nodes_power_parameters(
            rack.system_id, limit=None)  # Remove numeric limit.

        # The total size of the JSON is less than 60kiB, but only a bit.
        nodes_json = map(json.dumps, nodes)
        nodes_json_lengths = map(len, nodes_json)
        nodes_json_length = sum(nodes_json_lengths)
        expected_maximum = 60 * (2**10)  # 60kiB
        self.expectThat(nodes_json_length, LessThan(expected_maximum + 1))
        expected_minimum = 50 * (2**10)  # 50kiB
        self.expectThat(nodes_json_length, GreaterThan(expected_minimum - 1))
예제 #17
0
 def test_change_searchengine(self):
     settings = self.open_settings()
     searchengine = settings.get_searchengine_entry()
     old_engine = searchengine.currentSearchEngineDisplayName
     self.assertThat(old_engine, NotEquals(""))
     self.pointing_device.click_object(searchengine)
     searchengine_page = settings.get_searchengine_page()
     self.assertThat(
         lambda: len(
             searchengine_page.select_many(objectName="searchEngineDelegate"
                                           )), Eventually(GreaterThan(1)))
     delegates = searchengine_page.select_many(
         objectName="searchEngineDelegate")
     delegates.sort(key=lambda delegate: delegate.objectName)
     new_index = -1
     for (i, delegate) in enumerate(delegates):
         checkbox = delegate.select_single(uitk.CheckBox)
         if (new_index == -1) and not checkbox.checked:
             new_index = i
         self.assertThat(checkbox.checked,
                         Equals(delegate.displayName == old_engine))
     new_engine = delegates[new_index].displayName
     self.assertThat(new_engine, NotEquals(old_engine))
     self.pointing_device.click_object(delegates[new_index].select_single(
         uitk.CheckBox))
     searchengine_page.wait_until_destroyed()
     self.assertThat(searchengine.currentSearchEngineDisplayName,
                     Eventually(Equals(new_engine)))
 def test_cache_by_bug_notification_level(self):
     # The BugNotificationRecipients set is cached by notification level
     # to avoid duplicate work. The returned set is copy of the cached set.
     subscriber = self.factory.makePerson()
     product = self.factory.makeProduct()
     with person_logged_in(subscriber):
         subscription = product.addBugSubscription(subscriber, subscriber)
         bug_filter = subscription.bug_filters[0]
         bug_filter.bug_notification_level = BugNotificationLevel.COMMENTS
     bug = self.factory.makeBug(target=product)
     # The factory call queued LIFECYCLE and COMMENT notifications.
     bug.clearBugNotificationRecipientsCache()
     levels = [
         BugNotificationLevel.LIFECYCLE,
         BugNotificationLevel.METADATA,
         BugNotificationLevel.COMMENTS,
     ]
     for level in levels:
         with StormStatementRecorder() as recorder:
             first_recipients = bug.getBugNotificationRecipients(
                 level=level)
             self.assertThat(recorder, HasQueryCount(GreaterThan(1)))
         with StormStatementRecorder() as recorder:
             second_recipients = bug.getBugNotificationRecipients(
                 level=level)
             self.assertThat(recorder, HasQueryCount(Equals(0)))
         self.assertContentEqual([bug.owner, subscriber], first_recipients)
         self.assertContentEqual(first_recipients, second_recipients)
         self.assertIsNot(first_recipients, second_recipients)
예제 #19
0
 def test_patch(self):
     representation = self.webservice.get(self.webhook_url,
                                          api_version='devel').jsonBody()
     self.assertThat(
         representation,
         ContainsDict({
             'active': Equals(True),
             'delivery_url': Equals('http://example.com/ep'),
             'event_types': Equals([])
         }))
     old_mtime = representation['date_last_modified']
     patch = json.dumps({
         'active': False,
         'delivery_url': 'http://example.com/ep2',
         'event_types': ['git:push:0.1']
     })
     self.webservice.patch(self.webhook_url,
                           'application/json',
                           patch,
                           api_version='devel')
     representation = self.webservice.get(self.webhook_url,
                                          api_version='devel').jsonBody()
     self.assertThat(
         representation,
         ContainsDict({
             'active': Equals(False),
             'delivery_url': Equals('http://example.com/ep2'),
             'date_last_modified': GreaterThan(old_mtime),
             'event_types': Equals(['git:push:0.1'])
         }))
예제 #20
0
    def test_jobs_with_retry_exceptions_are_queued_again(self):
        # A job that raises a retry error is automatically queued
        # and executed again.
        self.useFixture(
            FeatureFixture(
                {'jobs.celery.enabled_classes': 'TestJobWithRetryError'}))

        # Set scheduled_start on the job to ensure that retry delays
        # override it.
        job = TestJobWithRetryError(scheduled_start=datetime.now(UTC) +
                                    timedelta(seconds=1))
        job.celeryRunOnCommit()
        transaction.commit()

        count = 0
        while count < 300 and job.is_pending:
            # We have a maximum wait of one minute.  We should not get
            # anywhere close to that on developer machines (10 seconds was
            # working fine), but when the test suite is run in parallel we
            # can need a lot more time (see bug 1007576).
            sleep(0.2)
            count += 1
            transaction.abort()

        # Collect the start times recorded by the job.
        dates_started = [
            iso8601.parse_date(d)
            for d in job.job.base_json_data['dates_started']
        ]

        # The first attempt's lease is set to the end of the job, so the
        # second attempt should start roughly 5 seconds after the first. The
        # third attempt should start roughly 5 seconds after the second.
        self.assertThat(dates_started, HasLength(3))
        self.assertThat(
            dates_started,
            MatchesListwise([
                MatchesAll(),
                MatchesAll(
                    GreaterThan(dates_started[0] + timedelta(seconds=4)),
                    LessThan(dates_started[0] + timedelta(seconds=8))),
                MatchesAll(
                    GreaterThan(dates_started[1] + timedelta(seconds=4)),
                    LessThan(dates_started[1] + timedelta(seconds=8))),
            ]))
        self.assertEqual(3, job.attempt_count)
        self.assertEqual(JobStatus.COMPLETED, job.status)
예제 #21
0
 def test_clear_with_multiple_lines(self):
     # This is a regrestion test for http://pad.lv/1359167
     self.simple_text_area.write(
         'Long text that will make it wrap into multiple lines.')
     self.assertThat(self.simple_text_area.lineCount, GreaterThan(1))
     self.simple_text_area._go_to_start()
     self.simple_text_area.clear()
     self.assertEqual(self.simple_text_area.text, '')
예제 #22
0
 def test_default(self):
     """
     There are default values for the delay and maximum time parameters
     accepted by ``get_default_retry_steps``.
     """
     steps = get_default_retry_steps()
     self.assertThat(steps, AllMatch(IsInstance(timedelta)))
     self.assertThat(steps, AllMatch(GreaterThan(timedelta())))
예제 #23
0
 def test_show_list_of_suggestions(self):
     suggestions = self.main_window.get_suggestions()
     self.assert_suggestions_eventually_hidden()
     self.address_bar.focus()
     self.assert_suggestions_eventually_shown()
     self.assertThat(suggestions.count, Eventually(GreaterThan(0)))
     self.address_bar.clear()
     self.assert_suggestions_eventually_hidden()
예제 #24
0
 def eval_expression_in_page_unsafe(self, expr):
     webview = self.get_webviewContainer()
     prev_emissions = self.watcher.num_emissions
     webview.slots.evalInPageUnsafe(expr)
     self.assertThat(
         lambda: self.watcher.num_emissions,
         Eventually(GreaterThan(prev_emissions)))
     return webview.get_signal_emissions('resultUpdated(QString)')[-1][0]
예제 #25
0
 def open_panel_menu(self):
     panel = self.unity.panels.get_panel_for_monitor(0)
     self.assertThat(lambda: len(panel.menus.get_entries()),
                     Eventually(GreaterThan(0)))
     self.addCleanup(self.keyboard.press_and_release, "Escape")
     self.keybinding("panel/open_first_menu")
     self.assertThat(self.unity.panels.get_active_indicator,
                     Eventually(NotEquals(None)))
예제 #26
0
    def test_comparison(self):
        """
        The binary comparison operations work on ``KubernetesError`` as expected.
        """
        model = v1_5_model

        a1 = KubernetesError(200, model.v1.Status(status=u"A"))
        a2 = KubernetesError(200, model.v1.Status(status=u"A"))
        b = KubernetesError(201, model.v1.Status(status=u"A"))
        c = KubernetesError(200, model.v1.Status(status=u"B"))

        # a1 == a2
        self.expectThat(a1, Equals(a2))
        # not (a1 != a2)
        self.expectThat(a1, Not(NotEquals(a2)))
        # not (a1 > a2)
        self.expectThat(a1, Not(GreaterThan(a2)))
        # not (a1 < a2)
        self.expectThat(a1, Not(LessThan(a2)))

        # not (a1 == b)
        self.expectThat(a1, Not(Equals(b)))
        # a1 != b
        self.expectThat(a1, NotEquals(b))
        # a1 < b
        self.expectThat(a1, LessThan(b))
        # not (a1 > b)
        self.expectThat(a1, Not(GreaterThan(b)))

        # not (a1 == c)
        self.expectThat(a1, Not(Equals(b)))
        # a1 != c
        self.expectThat(a1, NotEquals(b))
        # a1 < c
        self.expectThat(a1, LessThan(c))
        # not (a1 > c)
        self.expectThat(a1, Not(GreaterThan(c)))

        largest = KubernetesError(999, model.v1.Status(status=u"Z"))
        smallest = KubernetesError(1, model.v1.Status(status=u"A"))

        # a1 < largest
        self.expectThat(a1, LessThan(largest))
        # a1 > smallest
        self.expectThat(a1, GreaterThan(smallest))
예제 #27
0
 def test_launcher_keynav_prev_works(self):
     """Must be able to move backwards while in keynav mode."""
     self.start_keynav_with_cleanup_cancel()
     self.launcher_instance.key_nav_next(self.launcher_position)
     self.assertThat(self.unity.launcher.key_nav_selection,
                     Eventually(GreaterThan(0)))
     self.launcher_instance.key_nav_prev(self.launcher_position)
     self.assertThat(self.unity.launcher.key_nav_selection,
                     Eventually(Equals(0)))
예제 #28
0
 def test_time_is_now(self):
     # utc_now() returns a timestamp which is now.
     LessThanOrEqual = lambda x: MatchesAny(LessThan(x), Equals(x))
     GreaterThanOrEqual = lambda x: MatchesAny(GreaterThan(x), Equals(x))
     old_now = datetime.utcnow().replace(tzinfo=UTC)
     now = utc_now()
     new_now = datetime.utcnow().replace(tzinfo=UTC)
     self.assertThat(now, GreaterThanOrEqual(old_now))
     self.assertThat(now, LessThanOrEqual(new_now))
예제 #29
0
 def test_long_elapsed_time_increases(self):
     with sleep.mocked():
         last_elapsed = None
         for elapsed in Timeout.long():
             if last_elapsed is not None:
                 self.assertThat(elapsed, GreaterThan(last_elapsed))
             else:
                 self.assertEqual(elapsed, 0.0)
             last_elapsed = elapsed
예제 #30
0
 def eval_expression_in_page_unsafe(self, expr):
     webview = self.get_webviewContainer()
     p = self.watcher.num_emissions
     webview.slots.evalInPageUnsafe(expr)
     self.assertThat(lambda: self.watcher.num_emissions,
                     Eventually(GreaterThan(p)))
     results = json.loads(
         webview.get_signal_emissions('resultUpdated(QString)')[-1][0])
     return 'result' in results and results['result'] or None