本文整理汇总了Python中avocado.models.DataConcept.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DataConcept.delete方法的具体用法?Python DataConcept.delete怎么用?Python DataConcept.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avocado.models.DataConcept
的用法示例。
在下文中一共展示了DataConcept.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_all_category_sort
# 需要导入模块: from avocado.models import DataConcept [as 别名]
# 或者: from avocado.models.DataConcept import delete [as 别名]
def test_get_all_category_sort(self):
# Create some temporary concepts and categories.
cat1 = DataCategory(name='Category1', order=2.0, published=True)
cat1.save()
c1 = DataConcept(name='B', published=True, category=cat1, order=1)
c1.save()
field1 = DataConceptField(concept=c1, field=self.name_field, order=1)
field1.save()
c2 = DataConcept(name='C', published=True, category=cat1, order=2)
c2.save()
field2 = DataConceptField(concept=c2, field=self.name_field, order=1)
field2.save()
c3 = DataConcept(name='A', published=True, category=cat1, order=3)
c3.save()
field3 = DataConceptField(concept=c3, field=self.name_field, order=1)
field3.save()
# Check that category ordering is happening by default.
response = self.client.get('/api/concepts/',
HTTP_ACCEPT='application/json')
self.assertEqual(response.status_code, codes.ok)
self.assertEqual(len(json.loads(response.content)), 5)
names = [concept.get('name', '') for concept in
json.loads(response.content)]
self.assertEqual(names, ['Title', 'Name', 'B', 'C', 'A'])
# Reverse the ordering of the categories.
response = self.client.get('/api/concepts/',
{'order': 'desc'},
HTTP_ACCEPT='application/json')
self.assertEqual(response.status_code, codes.ok)
self.assertEqual(len(json.loads(response.content)), 5)
names = [concept.get('name', '') for concept in
json.loads(response.content)]
self.assertEqual(names, ['B', 'C', 'A', 'Title', 'Name'])
# Order by concept name in addition to category.
response = self.client.get('/api/concepts/',
{'sort': 'name'},
HTTP_ACCEPT='application/json')
self.assertEqual(response.status_code, codes.ok)
self.assertEqual(len(json.loads(response.content)), 5)
names = [concept.get('name', '') for concept in
json.loads(response.content)]
self.assertEqual(names, ['Name', 'Title', 'A', 'B', 'C'])
# Reverse the name and category sorting.
response = self.client.get('/api/concepts/',
{'sort': 'name', 'order': 'desc'},
HTTP_ACCEPT='application/json')
self.assertEqual(response.status_code, codes.ok)
self.assertEqual(len(json.loads(response.content)), 5)
names = [concept.get('name', '') for concept in
json.loads(response.content)]
self.assertEqual(names, ['C', 'B', 'A', 'Title', 'Name'])
c1.delete()
c2.delete()
c3.delete()
field1.delete()
field2.delete()
field3.delete()
cat1.delete()