コード例 #1
0
 def test_update_last_visited_concepts(self):
     c = Concept()
     c.id= 2
     c.labels = [Label('test', language_id='en-us')]
     update_last_visited_concepts(self.request, {'label': c.label(), 'url': 'http://test.test/{0}'.format(55)})
     c = Concept()
     c.id= 33
     c.labels = [Label('test', language_id='nl-be')]
     update_last_visited_concepts(self.request, {'label': c.label(), 'url': 'http://test.test/{0}'.format(2)})
     self.assertEqual(2, len(self.request.session['last_visited']))
コード例 #2
0
 def test_update_last_visited_concepts(self):
     c = Concept()
     c.id = 2
     c.labels = [Label('test', language_id='en-us')]
     update_last_visited_concepts(self.request, {
         'label': c.label(),
         'url': 'http://test.test/{0}'.format(55)
     })
     c = Concept()
     c.id = 33
     c.labels = [Label('test', language_id='nl-be')]
     update_last_visited_concepts(self.request, {
         'label': c.label(),
         'url': 'http://test.test/{0}'.format(2)
     })
     self.assertEqual(2, len(self.request.session['last_visited']))
コード例 #3
0
def filter_by_mock_concept(**kwargs):
    filter_mock = Mock()
    concept_id = None
    conceptscheme_id = None
    if 'concept_id' in kwargs:
        concept_id = kwargs['concept_id']
    if 'conceptscheme_id' in kwargs:
        conceptscheme_id = kwargs['conceptscheme_id']
    if concept_id == '1':
        c = Concept(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
        c.type = 'concept'
        label_mock = Mock()
        label_mock.label = 'test'
        c.label = Mock(return_value=label_mock)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '3':
        c = Collection(concept_id=concept_id,
                       conceptscheme_id=conceptscheme_id)
        c.type = 'collection'
        label_mock = Mock()
        label_mock.label = 'test'
        c.label = Mock(return_value=label_mock)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '555':
        c = Thing(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '666':
        raise NoResultFound

    a_concept = Concept(concept_id=7895,
                        conceptscheme_id=conceptscheme_id,
                        type='concept')
    a_labels = [
        Label(label='De Paardekastanje', language_id='nl'),
        Label(label='The Chestnut', language_id='en'),
        Label(label='la châtaigne', language_id='fr')
    ]
    a_concept.labels = a_labels
    b_concept = Concept(concept_id=9863,
                        conceptscheme_id=conceptscheme_id,
                        type='concept')
    b_labels = [Label(label='test', language_id='nl')]
    b_concept.labels = b_labels
    filter_mock.all = Mock(return_value=[a_concept, b_concept])
    return filter_mock
コード例 #4
0
 def test_update_last_visited_concepts_max(self):
     for id in range(50):
         c = Concept()
         c.id = id
         c.labels = [Label('test', language_id='en-us')]
         update_last_visited_concepts(self.request, {'label': c.label(), 'url': 'http://test.test/{0}'.format(id)})
     self.assertEqual(4, len(self.request.session['last_visited']))
     last = self.request.session['last_visited'].pop()
     self.assertEqual('http://test.test/49', last['url'])
コード例 #5
0
 def test_update_last_visited_concepts_max(self):
     for id in range(50):
         c = Concept()
         c.id = id
         c.labels = [Label('test', language_id='en-us')]
         update_last_visited_concepts(
             self.request, {
                 'label': c.label(),
                 'url': 'http://test.test/{0}'.format(id)
             })
     self.assertEqual(4, len(self.request.session['last_visited']))
     last = self.request.session['last_visited'].pop()
     self.assertEqual('http://test.test/49', last['url'])
コード例 #6
0
ファイル: test_views.py プロジェクト: anukat2015/atramhasis
def filter_by_mock_concept(**kwargs):
    filter_mock = Mock()
    concept_id = None
    conceptscheme_id = None
    if 'concept_id' in kwargs:
        concept_id = kwargs['concept_id']
    if 'conceptscheme_id' in kwargs:
        conceptscheme_id = kwargs['conceptscheme_id']
    if concept_id == '1':
        c = Concept(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
        c.type = 'concept'
        label_mock = Mock()
        label_mock.label = 'test'
        c.label = Mock(return_value=label_mock)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '3':
        c = Collection(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
        c.type = 'collection'
        label_mock = Mock()
        label_mock.label = 'test'
        c.label = Mock(return_value=label_mock)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '555':
        c = Thing(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
        filter_mock.one = Mock(return_value=c)
    elif concept_id == '666':
        raise NoResultFound

    a_concept = Concept(concept_id=7895, conceptscheme_id=conceptscheme_id, type='concept')
    a_labels = [Label(label='De Paardekastanje', language_id='nl'), Label(label='The Chestnut', language_id='en'),
                Label(label='la châtaigne', language_id='fr')]
    a_concept.labels = a_labels
    b_concept = Concept(concept_id=9863, conceptscheme_id=conceptscheme_id, type='concept')
    b_labels = [Label(label='test', language_id='nl')]
    b_concept.labels = b_labels
    filter_mock.all = Mock(return_value=[a_concept, b_concept])
    return filter_mock