예제 #1
0
    def test_identifier_filter_by_category(self):
        IdentifierFactory(referent=self.node, category='nopeid')
        identifiers_for_node = Identifier.find(Q('referent', 'eq', self.node))
        assert_equal(len(identifiers_for_node), 2)
        assert_items_equal(
            [identifier.category for identifier in identifiers_for_node],
            ['carpid', 'nopeid'])

        filter_url = self.url + '?filter[category]=carpid'
        new_res = self.app.get(filter_url)

        carpid_total = len(Identifier.find(Q('category', 'eq', 'carpid')))

        total = new_res.json['links']['meta']['total']
        assert_equal(total, carpid_total)
예제 #2
0
    def test_identifier_filter_by_category(self):
        IdentifierFactory(referent=self.registration, category='nopeid')
        identifiers_for_registration = Identifier.find(Q('referent', 'eq', self.registration))
        assert_equal(len(identifiers_for_registration), 2)
        assert_items_equal(
            [identifier.category for identifier in identifiers_for_registration],
            ['carpid', 'nopeid']
        )

        filter_url = self.url + '?filter[category]=carpid'
        new_res = self.app.get(filter_url)

        carpid_total = len(Identifier.find(Q('category', 'eq', 'carpid')))

        total = new_res.json['links']['meta']['total']
        assert_equal(total, carpid_total)
예제 #3
0
 def setUp(self):
     OsfTestCase.setUp(self)
     self.visible_contrib = AuthUserFactory()
     visible_contrib2 = AuthUserFactory(given_name=u'ヽ༼ ಠ益ಠ ༽ノ', family_name=u'ლ(´◉❥◉`ლ)')
     self.invisible_contrib = AuthUserFactory()
     self.node = RegistrationFactory(is_public=True)
     self.identifier = Identifier(referent=self.node, category='catid', value='cat:7')
     self.node.add_contributor(self.visible_contrib, visible=True)
     self.node.add_contributor(self.invisible_contrib, visible=False)
     self.node.add_contributor(visible_contrib2, visible=True)
     self.node.save()
예제 #4
0
def get_referent_by_identifier(category, value):
    """Look up identifier by `category` and `value` and redirect to its referent
    if found.
    """
    try:
        identifier = Identifier.find_one(Q("category", "eq", category) & Q("value", "eq", value))
    except NoResultsFound:
        raise HTTPError(http.NOT_FOUND)
    if identifier.referent.url:
        return redirect(identifier.referent.url)
    raise HTTPError(http.NOT_FOUND)
예제 #5
0
def get_referent_by_identifier(category, value):
    """Look up identifier by `category` and `value` and redirect to its referent
    if found.
    """
    try:
        identifier = Identifier.find_one(
            Q('category', 'eq', category) & Q('value', 'eq', value))
    except NoResultsFound:
        raise HTTPError(http.NOT_FOUND)
    if identifier.referent.url:
        return redirect(identifier.referent.url)
    raise HTTPError(http.NOT_FOUND)
예제 #6
0
    def setUp(self):
        super(TestNodeIdentifierList, self).setUp()
        self.user = AuthUserFactory()
        self.user_two = AuthUserFactory()

        self.node = NodeFactory(creator=self.user, is_public=True)
        self.identifier = IdentifierFactory(referent=self.node)
        self.url = '/{}nodes/{}/identifiers/'.format(API_BASE, self.node._id)

        self.res = self.app.get(self.url)
        self.data = self.res.json['data']

        self.all_identifiers = Identifier.find()
예제 #7
0
    def setUp(self):
        super(TestIdentifierList, self).setUp()
        self.user = AuthUserFactory()
        self.user_two = AuthUserFactory()

        self.registration = RegistrationFactory(creator=self.user, is_public=True)
        self.identifier = IdentifierFactory(referent=self.registration)
        self.url = '/{}registrations/{}/identifiers/'.format(API_BASE, self.registration._id)

        self.res = self.app.get(self.url)
        self.data = self.res.json['data']

        self.all_identifiers = Identifier.find()
예제 #8
0
    def test_identifier_filter_by_category(self):
        IdentifierFactory(referent=self.registration, category='nopeid')
        identifiers_for_registration = self.registration.identifiers
        assert_equal(identifiers_for_registration.count(), 2)
        assert_items_equal(
            list(
                identifiers_for_registration.values_list('category',
                                                         flat=True)),
            ['carpid', 'nopeid'])

        filter_url = self.url + '?filter[category]=carpid'
        new_res = self.app.get(filter_url)

        carpid_total = len(Identifier.find(Q('category', 'eq', 'carpid')))

        total = new_res.json['links']['meta']['total']
        assert_equal(total, carpid_total)
예제 #9
0
 def tearDown(self):
     super(TestRegistrationIdentifierList, self).tearDown()
     Identifier.remove()
예제 #10
0
 def tearDown(self):
     super(TestIdentifierDetail, self).tearDown()
     Identifier.remove()
예제 #11
0
 def get_object(self):
     return Identifier.load(self.kwargs['identifier_id'])
예제 #12
0
 def get_queryset(self):
     return Identifier.find(self.get_query_from_request())
예제 #13
0
파일: views.py 프로젝트: scooley/osf.io
 def get_queryset(self):
     return Identifier.find(self.get_query_from_request())
예제 #14
0
파일: views.py 프로젝트: scooley/osf.io
 def get_object(self):
     return Identifier.load(self.kwargs['identifier_id'])
예제 #15
0
 def test_fields(self):
     node = RegistrationFactory()
     identifier = Identifier(referent=node, category='catid', value='cat:7')
     assert_equal(identifier.referent, node)
     assert_equal(identifier.category, 'catid')
     assert_equal(identifier.value, 'cat:7')
예제 #16
0
 def tearDown(self):
     super(TestRegistrationIdentifierList, self).tearDown()
     Identifier.remove()
예제 #17
0
 def tearDown(self):
     super(TestIdentifierList, self).tearDown()
     Identifier.remove()
예제 #18
0
 def tearDown(self):
     super(TestNodeIdentifierList, self).tearDown()
     Identifier.remove()