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_session_builder_with_active_complaints(self):
        session = Builder(
            ActiveComplaints(crids=[123, 456])
        ).build()

        # FIXME: Change session's activeComplaints to active_complaints
        session.should.be.equal({'active_complaints': [123, 456]})
Esempio n. 3
0
    def get_redirect_url(self, term=None):
        suggestions = UrlMediatorSuggestionService().pick_the_best_matched_for(
            term)

        if suggestions:
            session_query = Builder(
                FilterTags(FromSuggestions(suggestions=suggestions))).build()
            session = Session(query=session_query)
            session.save()

            return session.get_absolute_url()

        return reverse('homepage')
Esempio n. 4
0
    def get_redirect_url(self, crid=None, category_slug=None, cat_hash=None):
        allegation = get_object_or_404(Allegation, crid=crid)
        cat_id = MobileUrlHashUtil().decode(cat_hash)
        category = get_object_or_404(AllegationCategory, pk=cat_id)

        session_query = Builder(
            FilterTags(
                AllegationCrid(crids=[allegation.crid]),
                AllegationType(categories=[(category.id,
                                            category.category)]))).build()
        session = Session(query=session_query)
        session.save()

        return session.get_absolute_url()
Esempio n. 5
0
    def test_session_builder_with_filter_tags(self):
        session = Builder(
            FilterTags(
                AllegationCrid(crids=[309887])
            )).build()

        # FIXME: Change session's activeComplaints to active_complaints
        session.should.be.equal({
            'filters': {
                'allegation__crid': [{
                    'category': 'allegation__crid',
                    'displayCategory': 'Allegation ID',
                    'displayValue': '309887',
                    'pinned': False,
                    'value': '309887'
                }]
            }
        }
        )
Esempio n. 6
0
 def test_node_name_should_be_root(self):
     Builder().should.have.property('node_name').being.equal('root')
Esempio n. 7
0
    def test_session_builder_with_active_officer(self):
        session = Builder(
            ActiveOfficers(pks=[123, 456])
        ).build()

        session.should.be.equal({'active_officers': [123, 456]})
Esempio n. 8
0
 def test_empty_session_builder(self):
     session = Builder().build()
     session.should.be.equal({})