本文整理汇总了Python中api_test.Helpers.createComposition方法的典型用法代码示例。如果您正苦于以下问题:Python Helpers.createComposition方法的具体用法?Python Helpers.createComposition怎么用?Python Helpers.createComposition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_test.Helpers
的用法示例。
在下文中一共展示了Helpers.createComposition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_for_non_existing_interpretation
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_get_for_non_existing_interpretation(self):
Helpers.createComposition()
url = '/compositions/1/interpretations/1/comments'
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, [])
示例2: test_get_throws_forbidden_when_user_not_authenticated
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_get_throws_forbidden_when_user_not_authenticated(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
url = self.url.format(user.id)
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
示例3: test_delete_throws_forbidden_for_not_authenticated_user
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_delete_throws_forbidden_for_not_authenticated_user(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
bookmark_data = {'bookmarks': [composition2.id]}
url = self.url.format(user.id)
response = self.client.delete(url, data=bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(user.bookmarks.all().count(), 2)
示例4: test_get_throws_forbidden_when_user_not_himself
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_get_throws_forbidden_when_user_not_himself(self):
user = Helpers.getUser(Helpers.USER1)
other_user = Helpers.getUser(Helpers.USER2)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
url = self.url.format(user.id)
self.client.login(
username=other_user.email, password=Helpers.USER2["password"])
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
示例5: test_delete_removes_bookmark_for_valid_authenticated_user
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_delete_removes_bookmark_for_valid_authenticated_user(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
bookmark_data = {'bookmarks': [composition2.id]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.delete(url, data=bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(user.bookmarks.all().count(), 1)
示例6: test_delete_throws_400_for_invalid_data
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_delete_throws_400_for_invalid_data(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data, {"bookmarks": "This field is required"})
self.assertEqual(user.bookmarks.all().count(), 2)
示例7: test_post_works_with_multiple_bookmarks_some_already_exist
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_post_works_with_multiple_bookmarks_some_already_exist(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
composition3 = Helpers.createComposition(user)
user.bookmarks.add(composition3)
bookmark_data = {'bookmarks': [composition1.id, composition2.id]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.post(url, data=bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(user.bookmarks.all().count(), 3)
示例8: test_get_returns_all_user_bookmarks
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_get_returns_all_user_bookmarks(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
user.bookmarks.add(composition1, composition2)
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected_response = [
self.createReponseBookmark(1, user.id, composition1.created)]
expected_response.append(
self.createReponseBookmark(2, user.id, composition2.created))
self.assertEqual(response.data, {'bookmarks': expected_response})
示例9: test_delete_for_multiple_bookmarks_all_not_existing
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_delete_for_multiple_bookmarks_all_not_existing(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
composition2 = Helpers.createComposition(user)
composition3 = Helpers.createComposition(user)
composition4 = Helpers.createComposition(user)
user.bookmarks.add(
composition1, composition2, composition3, composition4)
bookmark_data = {
'bookmarks': [composition2.id, 23, composition1.id, 59, 34]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.delete(url, data=bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(user.bookmarks.all().count(), 2)
示例10: test_post_adds_bookmark_for_valid_authenticated_user
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_post_adds_bookmark_for_valid_authenticated_user(self):
user = Helpers.getUser(Helpers.USER1)
composition = Helpers.createComposition(user)
bookmark_data = {'bookmarks': [composition.id]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.post(url, bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(user.bookmarks.all().count(), 1)
示例11: test_post_throws_forbidden_for_authenticated_user_not_himself
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_post_throws_forbidden_for_authenticated_user_not_himself(self):
user = Helpers.getUser(Helpers.USER1)
other_user = Helpers.getUser(Helpers.USER2)
composition = Helpers.createComposition(user)
bookmark_data = {'bookmarks': [composition.id]}
url = self.url.format(user.id)
self.client.login(
username=other_user.email, password=Helpers.USER2["password"])
response = self.client.post(url, bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(user.bookmarks.all().count(), 0)
示例12: test_delete_for_non_existing_bookmark_does_not_crash
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_delete_for_non_existing_bookmark_does_not_crash(self):
user = Helpers.getUser(Helpers.USER1)
composition1 = Helpers.createComposition(user)
user.bookmarks.add(composition1)
bookmark_data = {'bookmarks': [56, 89]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.delete(url, data=bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(user.bookmarks.all().count(), 1)
示例13: test_post_for_already_added_bookmark_acts_same_as_adding_new
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def test_post_for_already_added_bookmark_acts_same_as_adding_new(self):
user = Helpers.getUser(Helpers.USER1)
composition = Helpers.createComposition(user)
user.bookmarks.add(composition)
bookmark_data = {'bookmarks': [composition.id]}
url = self.url.format(user.id)
self.client.login(
username=user.email, password=Helpers.USER1["password"])
response = self.client.post(url, bookmark_data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(user.bookmarks.all().count(), 1)
示例14: createVote
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createComposition [as 别名]
def createVote(self):
composition = Helpers.createComposition()
return Vote.objects.get(composition=composition)