Example #1
0
    def test_department_browsing(self):
        self.start_harness()
        self.view.search_query = ''

        # Test "Current" department

        departments = self.view.browse_department('current')

        self.assertMatchResult(DepartmentMatcher().has_exactly(0).mode(
            DepartmentMatcherMode.STARTS_WITH).label('Current').all_label(
                '').parent_id('').parent_label('Current + Forecast').is_root(
                    False).is_hidden(False).match(departments))

        self.assertMatchResult(CategoryListMatcher().has_exactly(1).mode(
            CategoryListMatcherMode.BY_ID).category(
                CategoryMatcher("current").has_at_least(1)).match(
                    self.view.categories))

        # Test "Forecast" department

        departments = self.view.browse_department('forecast')

        self.assertMatchResult(DepartmentMatcher().has_exactly(0).mode(
            DepartmentMatcherMode.STARTS_WITH).label('Forecast').all_label(
                '').parent_id('').parent_label('Current + Forecast').is_root(
                    False).is_hidden(False).match(departments))

        self.assertMatchResult(CategoryListMatcher().has_exactly(1).mode(
            CategoryListMatcherMode.BY_ID).category(
                CategoryMatcher("forecast").has_at_least(1)).match(
                    self.view.categories))
Example #2
0
    def test_result_data_query(self):
        self.view.active_scope = 'goscope'
        test_query = "test_query"
        self.view.search_query = test_query

        self.assertMatchResult(CategoryListMatcher(
        ).has_at_least(1).mode(CategoryListMatcherMode.BY_ID).category(
            CategoryMatcher("category").has_at_least(1).
            mode(CategoryMatcherMode.BY_URI).result(
                ResultMatcher("http://localhost/" + test_query).properties({
                    'test_value_bool':
                    True
                }).properties({
                    'test_value_string':
                    "test_value" + test_query
                }).properties({
                    'test_value_int':
                    1999
                }).properties({
                    'test_value_float':
                    1.999
                }).dnd_uri("http://localhost_dnduri" +
                           test_query).
                art("https://pbs.twimg.com/profile_images/1117820653/5ttls5.jpg.png"
                    ))).match(self.view.categories))

        self.assertMatchResult(CategoryListMatcher(
        ).has_at_least(1).mode(CategoryListMatcherMode.BY_ID).category(
            CategoryMatcher("category").has_at_least(1).
            mode(CategoryMatcherMode.BY_URI).result(
                ResultMatcher("http://localhost2/" + test_query).properties({
                    'test_value_bool':
                    False
                }).properties({
                    'test_value_string': "test_value2" + test_query
                }).properties({
                    'test_value_int':
                    2000
                }).properties({
                    'test_value_float':
                    2.1
                }).dnd_uri("http://localhost_dnduri2" + test_query).properties(
                    {
                        'test_value_map': {
                            'value1': 1,
                            'value2': 'string_value'
                        }
                    }).properties({
                        'test_value_array':
                        [1999, "string_value"]
                    }).
                art("https://pbs.twimg.com/profile_images/1117820653/5ttls5.jpg.png"
                    ))).match(self.view.categories))
 def test_basic_result(self):
     self.assertMatchResult(CategoryListMatcher()
         .has_at_least(1)
         .mode(CategoryListMatcherMode.BY_ID)
         .category(CategoryMatcher("cat1")
                 .has_at_least(1)
                 .mode(CategoryMatcherMode.BY_URI)
                 .result(ResultMatcher("test:uri")
                 .properties({'title': 'result for: ""', 'art':'art'})
                 .dnd_uri("test:dnd_uri")
                 ))
         .match(self.view.categories))
Example #4
0
    def test_search_results(self):
        self.start_harness()
        self.view.search_query = 'Manchester,uk'

        match = CategoryListMatcher() \
            .has_exactly(2) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("current") \
                .title("Manchester, GB") \
                .has_at_least(1) \
                .result(ResultMatcher("2643123") \
                    .title("17.35°C") \
                    .art("http://openweathermap.org/img/w/03d.png") \
                    .subtitle("scattered clouds") ) ) \
            .category(CategoryMatcher("forecast") \
                .title("7 day forecast") \
                .has_at_least(7) \
                .result(ResultMatcher("800") \
                    .title("11.96°C to 18.83°C") \
                    .art("http://openweathermap.org/img/w/01d.png") \
                    .subtitle("sky is clear") ) \
                .result(ResultMatcher("501") \
                    .title("12.33°C to 18.59°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("803") \
                    .title("10.79°C to 17.11°C") \
                    .art("http://openweathermap.org/img/w/04d.png") \
                    .subtitle("broken clouds") ) \
                .result(ResultMatcher("501") \
                    .title("12.21°C to 15.98°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("500") \
                    .title("12.99°C to 15.73°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) \
                .result(ResultMatcher("501") \
                    .title("14.08°C to 17.64°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("501") \
                    .title("13.37°C to 15.52°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
Example #5
0
    def test_surfacing_results(self):
        self.start_harness()
        self.view.search_query = ''

        match = CategoryListMatcher() \
            .has_exactly(2) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("current") \
                .title("London, GB") \
                .has_at_least(1) \
                .result(ResultMatcher("2643743") \
                    .title("21.83°C") \
                    .art("http://openweathermap.org/img/w/02d.png") \
                    .subtitle("few clouds") ) ) \
            .category(CategoryMatcher("forecast") \
                .title("7 day forecast") \
                .has_at_least(7) \
                .result(ResultMatcher("500") \
                    .title("18.84°C to 25.09°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) \
                .result(ResultMatcher("501") \
                    .title("15.54°C to 20.86°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("802") \
                    .title("13.19°C to 19.58°C") \
                    .art("http://openweathermap.org/img/w/03d.png") \
                    .subtitle("scattered clouds") ) \
                .result(ResultMatcher("501") \
                    .title("13.46°C to 18.09°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("502") \
                    .title("15.39°C to 17.38°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("heavy intensity rain") ) \
                .result(ResultMatcher("501") \
                    .title("16.17°C to 18.44°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("500") \
                    .title("16.67°C to 19.02°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
Example #6
0
    def test_surfacing_results(self):
        self.start_harness()
        self.view.search_query = ''

        match = CategoryListMatcher() \
            .has_exactly(2) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("current") \
                .title("London, GB") \
                .has_at_least(1) \
                .result(ResultMatcher("2643743") \
                    .title("21.8°C") \
                    .art("http://openweathermap.org/img/w/02d.png") \
                    .subtitle("few clouds") ) ) \
            .category(CategoryMatcher("forecast") \
                .title("7 day forecast") \
                .has_at_least(7) \
                .result(ResultMatcher("1000000") \
                    .title("25.1°C to 18.8°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) \
                .result(ResultMatcher("1000001") \
                    .title("20.9°C to 15.5°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000002") \
                    .title("19.6°C to 13.2°C") \
                    .art("http://openweathermap.org/img/w/03d.png") \
                    .subtitle("scattered clouds") ) \
                .result(ResultMatcher("1000003") \
                    .title("18.1°C to 13.5°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000004") \
                    .title("17.4°C to 15.4°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("heavy intensity rain") ) \
                .result(ResultMatcher("1000005") \
                    .title("18.4°C to 16.2°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000006") \
                    .title("19°C to 16.7°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
Example #7
0
    def test_search_results(self):
        self.start_harness()
        self.view.search_query = 'Manchester,uk'

        match = CategoryListMatcher() \
            .has_exactly(2) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("current") \
                .title("Manchester, GB") \
                .has_at_least(1) \
                .result(ResultMatcher("2643123") \
                    .title("17.4°C") \
                    .art("http://openweathermap.org/img/w/03d.png") \
                    .subtitle("scattered clouds") ) ) \
            .category(CategoryMatcher("forecast") \
                .title("7 day forecast") \
                .has_at_least(7) \
                .result(ResultMatcher("1000000") \
                    .title("18.8°C to 12°C") \
                    .art("http://openweathermap.org/img/w/01d.png") \
                    .subtitle("sky is clear") ) \
                .result(ResultMatcher("1000001") \
                    .title("18.6°C to 12.3°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000002") \
                    .title("17.1°C to 10.8°C") \
                    .art("http://openweathermap.org/img/w/04d.png") \
                    .subtitle("broken clouds") ) \
                .result(ResultMatcher("1000003") \
                    .title("16°C to 12.2°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000004") \
                    .title("15.7°C to 13°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("light rain") ) \
                .result(ResultMatcher("1000005") \
                    .title("17.6°C to 14.1°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) \
                .result(ResultMatcher("1000006") \
                    .title("15.5°C to 13.4°C") \
                    .art("http://openweathermap.org/img/w/10d.png") \
                    .subtitle("moderate rain") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
Example #8
0
    def test_search_results_with_settings(self):
        self.start_harness()
        self.view.search_query = 'Manchester,uk'

        settings = self.view.settings
        settings.set("forecast", False)

        match = CategoryListMatcher() \
            .has_exactly(1) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("current") \
                .title("Manchester, GB") \
                .has_at_least(1) \
                .result(ResultMatcher("2643123") \
                    .title("17.35°C") \
                    .art("http://openweathermap.org/img/w/03d.png") \
                    .subtitle("scattered clouds") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
Example #9
0
    def test_search_results(self):
        self.start_harness()
        self.view.search_query = 'test'

        match = CategoryListMatcher() \
            .has_exactly(1) \
            .mode(CategoryListMatcherMode.BY_ID) \
            .category(CategoryMatcher("results") \
                .title("2 results") \
                .has_at_least(2) \
                .result(ResultMatcher("uri") \
                    .title("test") \
                    .art("art.png") \
                    .subtitle("subtitle") ) \
                .result(ResultMatcher("uri2") \
                    .title("test") \
                    .art("art2.png") \
                    .subtitle("subtitle2") ) ) \
            .match(self.view.categories)
        self.assertMatchResult(match)
    def test_preview_layouts(self):
        self.view.search_query = "layout"
        self.assertMatchResult(CategoryListMatcher()
                .has_at_least(1)
                .mode(CategoryListMatcherMode.STARTS_WITH)
                .category(CategoryMatcher("cat1")
                        .has_at_least(1)
                        .mode(CategoryMatcherMode.STARTS_WITH)
                        .result(ResultMatcher("test:layout"))
                        ).match(self.view.categories))

        pview = self.view.category(0).result(0).tap()
        self.assertIsInstance(pview, PreviewView)

        self.assertMatchResult(PreviewColumnMatcher().column(
                PreviewMatcher()
                    .widget(PreviewWidgetMatcher("img"))
                    .widget(PreviewWidgetMatcher("hdr"))
                    .widget(PreviewWidgetMatcher("desc"))
                    .widget(PreviewWidgetMatcher("actions"))
                ).match(pview.widgets))

        pview.column_count = 2
        self.assertMatchResult(PreviewColumnMatcher()
                 .column(PreviewMatcher()
                         .widget(PreviewWidgetMatcher("img")))
                 .column(PreviewMatcher()
                         .widget(PreviewWidgetMatcher("hdr"))
                         .widget(PreviewWidgetMatcher("desc"))
                         .widget(PreviewWidgetMatcher("actions"))
                        ).match(pview.widgets))

        pview.column_count = 1
        self.assertMatchResult(PreviewColumnMatcher()
                 .column(PreviewMatcher()
                         .widget(PreviewWidgetMatcher("img"))
                         .widget(PreviewWidgetMatcher("hdr"))
                         .widget(PreviewWidgetMatcher("desc"))
                         .widget(PreviewWidgetMatcher("actions"))
                        ).match(pview.widgets))
Example #11
0
 def test_basic_result(self):
     self.assertMatchResult(CategoryListMatcher().has_at_least(1).mode(
         CategoryListMatcherMode.BY_ID).category(
             CategoryMatcher("category").has_at_least(1).mode(
                 CategoryMatcherMode.BY_URI).title("Category").icon(
                     "")).match(self.view.categories))