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)
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)
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()
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()
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)
def get_queryset(self): return Identifier.find(self.get_query_from_request())