Esempio n. 1
0
    def test_session_build_from_suggestion(self):
        officer = OfficerFactory()
        rebuild_index()
        suggestions = UrlMediatorSuggestionService().make_suggestion(officer.officer_first)

        session = Builder(
            FilterTags(
                FromSuggestions(suggestions=suggestions)
            )).build()

        officer_name = "{officer_first} {officer_last}".format(
            officer_first=officer.officer_first,
            officer_last=officer.officer_last
        )

        session.should.have.length_of(1)
        session.should.be.equal({
            'filters': {
                'officer': [{
                    'category': 'officer',
                    'displayCategory': "Officer",
                    'displayValue': officer_name,
                    'pinned': False,
                    'value': officer.pk
                }]
            }
        })
Esempio n. 2
0
    def test_detect_suggest_type_officer_badge_number(self):
        OfficerFactory(star=123456)

        rebuild_index()

        data = self.get_suggestion('12')
        data.should.contain('Badge number')
Esempio n. 3
0
    def test_detect_suggest_type_officer_name(self):
        OfficerFactory(officer_first='Jerry', officer_last="Dao")

        rebuild_index()

        [self.get_suggestion(term).should.contain('Officer') for term in ['je', 'je da']]
        [self.get_suggestion(term).shouldnt.contain('Officer') for term in ['genie', 'je e']]
Esempio n. 4
0
    def test_detect_suggest_type_investigator(self):
        AllegationFactory(investigator__name='Someone Name')

        rebuild_index()

        data = self.get_suggestion('Some')
        data.should.contain('Investigator')
Esempio n. 5
0
    def test_detect_suggest_type_main_complaint_category(self):
        AllegationCategoryFactory(category='Bonding category')

        rebuild_index()

        data = self.get_suggestion('Bonding')
        data.should.contain('Category')
Esempio n. 6
0
    def test_suggest_city(self):
        AllegationFactory(city='Chicago IL 60616')

        rebuild_index()

        self.get_suggestion('616').should.contain('Zip Code')
        self.get_suggestion('123').shouldnt.contain('Zip Code')
        self.get_suggestion('Chi').shouldnt.contain('Zip Code')
    def test_redirect(self):
        officer = OfficerFactory()

        rebuild_index()
        self.visit('/')
        self.search_officer(officer)
        self.visit(self.mobile_url_for_current_request())
        self.until(lambda: MobileUrlBuilder().officer_page(officer) in self.browser.current_url)
Esempio n. 8
0
    def test_suggest_area_type(self):
        area = AreaFactory()

        rebuild_index()

        data = self.get_suggestion(area.name[0:3])
        data.should.contain('Area')
        data['Area'].should.have.length_of(1)
Esempio n. 9
0
    def test_search_session_alias(self):
        session_alias = SessionAliasFactory(title=fake.name())

        rebuild_index()

        data = self.get_suggestion(session_alias.alias[0:2])
        data.should.contain('Session')
        [x['suggestValue'] for x in data['Session']]\
            .should.contain(session_alias.title)
Esempio n. 10
0
    def test_redirect(self):
        officer = OfficerFactory()

        rebuild_index()
        self.visit('/')
        self.search_officer(officer)
        self.visit(self.mobile_url_for_current_request())
        self.until(lambda: MobileUrlBuilder().officer_page(officer) in self.
                   browser.current_url)
Esempio n. 11
0
    def test_officer_and_investigator_name_displayed_as_in_database(self):
        officer = OfficerFactory(officer_last='III')
        investigator = InvestigatorFactory(name='IIII')

        rebuild_index()

        search_text = 'ii'
        self.until(lambda: self.fill_in('.ui-autocomplete-input', search_text))
        self.until(lambda: self.find('.ui-autocomplete-input').get_attribute('value').should.equal(search_text))
        self.until(lambda: self.should_see_text(officer.officer_last))
        self.until(lambda: self.should_see_text(investigator.name))
Esempio n. 12
0
    def test_replace_old_filter_in_same_category(self):
        officer_allegation = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.search_officer(officer_allegation.officer)
        self.should_see_text(officer_allegation.officer.display_name)

        self.search_officer(self.officer_allegation.officer)
        self.should_see_text(self.officer_allegation.officer.display_name)
        self.should_not_see_text(officer_allegation.officer.display_name)
Esempio n. 13
0
    def test_officer_and_investigator_name_displayed_as_in_database(self):
        officer = OfficerFactory(officer_last='III')
        investigator = InvestigatorFactory(name='IIII')

        rebuild_index()

        search_text = 'ii'
        self.until(lambda: self.fill_in('.ui-autocomplete-input', search_text))
        self.until(lambda: self.find('.ui-autocomplete-input').get_attribute(
            'value').should.equal(search_text))
        self.until(lambda: self.should_see_text(officer.officer_last))
        self.until(lambda: self.should_see_text(investigator.name))
Esempio n. 14
0
    def test_replace_old_filter_in_same_category(self):
        officer_allegation = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.search_officer(officer_allegation.officer)
        self.should_see_text(officer_allegation.officer.display_name)

        self.search_officer(self.officer_allegation.officer)
        self.should_see_text(self.officer_allegation.officer.display_name)
        self.should_not_see_text(officer_allegation.officer.display_name)
    def test_build_responses(self):
        officer = OfficerFactory(officer_first='Jason',
                                 officer_last='Van Dyke')
        # Temporary disable investigator response since mobile version doesn't have investigator page yet
        # investigator = InvestigatorFactory(name='Daniel Neubeck')
        names = {'Jason Van Dyke': [], 'Daniel Neubeck': []}

        rebuild_index()

        responses = TwitterBotResponsesService(names).build_responses()
        responses_str = [x.message for x in responses]

        responses_str.should.contain(officer.display_name)
Esempio n. 16
0
    def test_detect_suggest_type_complaint_id_number(self):
        AllegationFactory(crid=123456)

        rebuild_index()

        data = self.get_suggestion('1234')
        data.should.contain('Allegation ID')

        data = self.get_suggestion('123')
        data.shouldnt.contain('Allegation ID')

        data = self.get_suggestion('8908')
        data.shouldnt.contain('Allegation ID')
Esempio n. 17
0
    def test_allegation_summary_multiple_word_term(self):
        expected_allegations = [
            OfficerAllegationFactory(allegation=AllegationFactory(
                summary='some some really long summary'))]
        OfficerAllegationFactory(
            allegation=AllegationFactory(summary='I am so sorry some'))

        rebuild_index()

        query_string = 'allegation_summary=some some'
        expected_ids = [allegation.id for allegation in expected_allegations]

        self.check_built_query(query_string, expected_ids)
Esempio n. 18
0
    def setUp(self):
        super(AllegationFilterTestCase, self).setUp()
        self.allegation_category = AllegationCategoryFactory()
        for _filter in FILTERS:
            for final_finding in FILTERS[_filter]:
                # Make sure it doesn't break the disciplined test
                OfficerAllegationFactory(
                    final_finding=final_finding, cat=self.allegation_category,
                    final_outcome_class='disciplined')

        rebuild_index()

        self.visit_home()
        self.hide_chat_box()
Esempio n. 19
0
    def test_search_with_alias(self):
        officer = OfficerFactory()
        alias = AliasFactory(target=str(officer))

        rebuild_index()

        data = self.get_suggestion(alias.alias[0:2])
        data.should.contain('Officer')

        officer_ids = [x['tagValue']['displayValue'] for x in data['Officer']]
        officer_ids.should.contain('{first} {last}'.format(first=officer.officer_first, last=officer.officer_last))

        alias = Alias.objects.get(id=alias.id)
        alias.num_usage.should.equal(1)
Esempio n. 20
0
    def setUp(self):
        super(AllegationFilterTestCase, self).setUp()
        self.allegation_category = AllegationCategoryFactory()
        for _filter in FILTERS:
            for final_finding in FILTERS[_filter]:
                # Make sure it doesn't break the disciplined test
                OfficerAllegationFactory(final_finding=final_finding,
                                         cat=self.allegation_category,
                                         final_outcome_class='disciplined')

        rebuild_index()

        self.visit_home()
        self.hide_chat_box()
Esempio n. 21
0
    def test_suggest_session_alias(self):
        alias = 'alias'
        query = alias[:3]
        not_searchable = SessionFactory(title='not searchable')
        session = SessionFactory(title='searchable')
        SessionAliasFactory(alias=alias, session=session)

        rebuild_index()

        self.fill_in('#autocomplete', query)
        self.until(lambda: self.element_by_classname_and_text(
            'autocomplete-session', session.title).should.be.ok)
        self.element_by_classname_and_text('autocomplete-session',
                                           not_searchable.title).shouldnt.be.ok
Esempio n. 22
0
    def test_display_suggestions_upon_typing(self):
        officer = OfficerFactory(officer_first='Jerry')
        OfficerFactory(officer_first='Jee')

        rebuild_index()

        self.visit('/?no_disclaimer=1#!/data-tools')
        search_text = 'Je'
        self.until(lambda: self.find('.ui-autocomplete-input').send_keys(search_text))
        self.until(lambda: self.should_see_text(search_text))
        self.until(lambda: self.should_see_text(officer.officer_last))

        self.find('.ui-autocomplete-input').send_keys(Keys.ARROW_DOWN)
        self.find('.ui-autocomplete-input').get_attribute('value').should.equal(search_text)
Esempio n. 23
0
    def test_suggest_session_alias(self):
        alias = 'alias'
        query = alias[:3]
        not_searchable = SessionFactory(title='not searchable')
        session = SessionFactory(title='searchable')
        SessionAliasFactory(alias=alias, session=session)

        rebuild_index()

        self.fill_in('#autocomplete', query)
        self.until(
            lambda: self.element_by_classname_and_text(
                'autocomplete-session', session.title).should.be.ok)
        self.element_by_classname_and_text(
            'autocomplete-session', not_searchable.title).shouldnt.be.ok
    def test_build_responses(self):
        officer = OfficerFactory(officer_first='Jason', officer_last='Van Dyke')
        # Temporary disable investigator response since mobile version doesn't have investigator page yet
        # investigator = InvestigatorFactory(name='Daniel Neubeck')
        names = {
            'Jason Van Dyke': [],
            'Daniel Neubeck': []
        }

        rebuild_index()

        responses = TwitterBotResponsesService(names).build_responses()
        responses_str = [x.message for x in responses]

        responses_str.should.contain(officer.display_name)
Esempio n. 25
0
    def test_save_current_filter_in_session(self):
        officer_allegation = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.find("body").click()

        self.find(".ui-autocomplete-input").send_keys(
            officer_allegation.officer.officer_first)

        self.until(lambda: self.find(".autocomplete-officer").click())
        self.until_ajax_complete()
        self.browser.refresh()
        self.until(lambda: self.find("#filter-tags").text.should.contain(
            officer_allegation.officer.display_name))
Esempio n. 26
0
    def test_display_suggestions_upon_typing(self):
        officer = OfficerFactory(officer_first='Jerry')
        OfficerFactory(officer_first='Jee')

        rebuild_index()

        self.visit('/?no_disclaimer=1#!/data-tools')
        search_text = 'Je'
        self.until(
            lambda: self.find('.ui-autocomplete-input').send_keys(search_text))
        self.until(lambda: self.should_see_text(search_text))
        self.until(lambda: self.should_see_text(officer.officer_last))

        self.find('.ui-autocomplete-input').send_keys(Keys.ARROW_DOWN)
        self.find('.ui-autocomplete-input').get_attribute(
            'value').should.equal(search_text)
Esempio n. 27
0
    def test_go_to_suggested_session(self):
        alias = 'alias'
        query = alias[:3]
        session = SessionFactory()
        SessionAliasFactory(alias=alias, session=session)

        rebuild_index()

        current_url = self.browser.current_url

        self.find('#autocomplete').send_keys(query)
        self.until(lambda: self.find('.autocomplete-session').click())
        self.until(lambda: self.browser.current_url != current_url)

        cloned_session = Session.objects.get(share_from=session)
        self.browser.current_url.should.contain(cloned_session.hash_id)
Esempio n. 28
0
    def test_go_to_suggested_session(self):
        alias = 'alias'
        query = alias[:3]
        session = SessionFactory()
        SessionAliasFactory(alias=alias, session=session)

        rebuild_index()

        current_url = self.browser.current_url

        self.find('#autocomplete').send_keys(query)
        self.until(lambda: self.find('.autocomplete-session').click())
        self.until(lambda: self.browser.current_url != current_url)

        cloned_session = Session.objects.get(share_from=session)
        self.browser.current_url.should.contain(cloned_session.hash_id)
Esempio n. 29
0
    def test_build_responses(self):
        officer = OfficerFactory()

        rebuild_index()

        ResponseTemplateFactory(response_type='officer')
        originating_tweet = TweetFactory(text=officer.display_name)
        incoming_tweet = TweetFactory(retweeted_tweet=originating_tweet)
        self.service.get_recipients = MagicMock(return_value=['r1', 'r2'])

        responses = self.service.build_responses(incoming_tweet)

        len(responses).should.equal(1)
        for response in responses:
            response.recipients.should.equal(['r1', 'r2'])
            response.incoming_tweet.should.be(incoming_tweet)
            response.originating_tweet.should.be(originating_tweet)
Esempio n. 30
0
    def test_save_current_filter_in_session(self):
        officer_allegation = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.find("body").click()

        self.find(".ui-autocomplete-input").send_keys(
            officer_allegation.officer.officer_first)

        self.until(lambda: self.find(".autocomplete-officer").click())
        self.until_ajax_complete()
        self.browser.refresh()
        self.until(
            lambda: self.find("#filter-tags").text
            .should.contain(officer_allegation.officer.display_name))
Esempio n. 31
0
    def test_build_responses(self):
        officer = OfficerFactory()

        rebuild_index()

        ResponseTemplateFactory(response_type='officer')
        originating_tweet = TweetFactory(text=officer.display_name)
        incoming_tweet = TweetFactory(retweeted_tweet=originating_tweet)
        self.service.get_recipients = MagicMock(return_value=['r1', 'r2'])

        responses = self.service.build_responses(incoming_tweet)

        len(responses).should.equal(1)
        for response in responses:
            response.recipients.should.equal(['r1', 'r2'])
            response.incoming_tweet.should.be(incoming_tweet)
            response.originating_tweet.should.be(originating_tweet)
Esempio n. 32
0
    def test_see_session_query_on_reload(self):
        self.visit_home()
        officer = self.officer_allegation.officer

        rebuild_index()

        self.until(lambda: self.fill_in('.ui-autocomplete-input', officer.
                                        officer_first))
        self.until_ajax_complete()
        self.until(lambda: self.find(".autocomplete-officer").is_displayed())
        self.find(".autocomplete-officer").click()

        self.should_see_text(officer.officer_first)
        self.should_see_text(officer.officer_last)

        self.browser.refresh()
        self.until(self.ajax_complete)
        self.until(lambda: self.should_see_text(officer.officer_first))
        self.should_see_text(officer.officer_last)
Esempio n. 33
0
    def test_can_not_change_filter_in_embed_mode(self):
        rebuild_index()

        self.link('Exit mode').click()

        self.until(lambda: self.fill_in(
            '.ui-autocomplete-input',
            self.officer_allegation.officer.officer_first))

        self.until(lambda: self.find(".autocomplete-officer").is_displayed())
        self.find(".autocomplete-officer").click()
        len(self.find_all("#filter-tags .tag")).should.equal(1)

        self.link('Embed Mode').click()
        self.until(lambda: self.find("body").has_class("embedding"))
        self.browser.execute_script("jQuery(window).scrollTop(0)")

        self.find("#filter-tags .tag .remove").click()
        len(self.find_all("#filter-tags .tag")).should.equal(1)
Esempio n. 34
0
    def test_display_dotted_underlining(self):
        OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.element_exist(".site-title .after-title-input").should.be.false

        # Select a filter
        self.click_on_sunburst(2)
        # Toggle share bar
        self.find('button .fa.fa-share').click()
        self.until_ajax_complete()

        self.element_exist(".site-title .after-title-input").should.be.true

        # Remove Filter
        self.click_on_sunburst(1)

        self.element_exist(".site-title .after-title-input").should.be.false
Esempio n. 35
0
    def test_display_dotted_underlining(self):
        OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.element_exist(".site-title .after-title-input").should.be.false

        # Select a filter
        self.click_on_sunburst(2)
        # Toggle share bar
        self.find('button .fa.fa-share').click()
        self.until_ajax_complete()

        self.element_exist(".site-title .after-title-input").should.be.true

        # Remove Filter
        self.click_on_sunburst(1)

        self.element_exist(".site-title .after-title-input").should.be.false
Esempio n. 36
0
    def test_see_session_query_on_reload(self):
        self.visit_home()
        officer = self.officer_allegation.officer

        rebuild_index()

        self.until(
            lambda:
            self.fill_in('.ui-autocomplete-input', officer.officer_first))
        self.until_ajax_complete()
        self.until(lambda: self.find(".autocomplete-officer").is_displayed())
        self.find(".autocomplete-officer").click()

        self.should_see_text(officer.officer_first)
        self.should_see_text(officer.officer_last)

        self.browser.refresh()
        self.until(self.ajax_complete)
        self.until(lambda: self.should_see_text(officer.officer_first))
        self.should_see_text(officer.officer_last)
Esempio n. 37
0
    def test_pin_tag(self):
        officer_allegation = OfficerAllegationFactory()
        another = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.search_officer(officer_allegation.officer)
        self.should_see_text(officer_allegation.officer.display_name)

        self.find('.tag > .pin').click()
        self.until(lambda: self.find('.tag').get_attribute('class').should.
                   contain('pinned'))

        self.search_officer(self.officer_allegation.officer)
        self.should_see_text(self.officer_allegation.officer.display_name)
        self.should_see_text(officer_allegation.officer.display_name)

        self.search_officer(another.officer)
        self.should_see_text(another.officer.display_name)
        self.should_see_text(officer_allegation.officer.display_name)
        self.should_not_see_text(self.officer_allegation.officer.display_name)
Esempio n. 38
0
    def test_pin_tag(self):
        officer_allegation = OfficerAllegationFactory()
        another = OfficerAllegationFactory()

        rebuild_index()

        self.visit_home()
        self.search_officer(officer_allegation.officer)
        self.should_see_text(officer_allegation.officer.display_name)

        self.find('.tag > .pin').click()
        self.until(
            lambda:
            self.find('.tag').get_attribute('class').should.contain('pinned'))

        self.search_officer(self.officer_allegation.officer)
        self.should_see_text(self.officer_allegation.officer.display_name)
        self.should_see_text(officer_allegation.officer.display_name)

        self.search_officer(another.officer)
        self.should_see_text(another.officer.display_name)
        self.should_see_text(officer_allegation.officer.display_name)
        self.should_not_see_text(self.officer_allegation.officer.display_name)
Esempio n. 39
0
    def setUp(self):
        self.investigator = InvestigatorFactory(name='Jason Van Dyke')

        rebuild_index()
Esempio n. 40
0
 def rebuild_index(self):
     rebuild_index()
Esempio n. 41
0
    def setUp(self):
        self.officer = OfficerFactory(officer_first='Jason', officer_last='Van Dyke')

        rebuild_index()