本文整理汇总了Python中tests.factories.ProjectFactory.remove_tag方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory.remove_tag方法的具体用法?Python ProjectFactory.remove_tag怎么用?Python ProjectFactory.remove_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.ProjectFactory
的用法示例。
在下文中一共展示了ProjectFactory.remove_tag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestNodeLogList
# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import remove_tag [as 别名]
class TestNodeLogList(ApiTestCase):
def setUp(self):
super(TestNodeLogList, self).setUp()
self.user = AuthUserFactory()
self.contrib = AuthUserFactory()
self.creator = AuthUserFactory()
self.user_auth = Auth(self.user)
self.NodeLogFactory = ProjectFactory()
self.pointer = ProjectFactory()
self.private_project = ProjectFactory(is_public=False, creator=self.user)
self.private_url = '/{}nodes/{}/logs/'.format(API_BASE, self.private_project._id)
self.public_project = ProjectFactory(is_public=True, creator=self.user)
self.public_url = '/{}nodes/{}/logs/'.format(API_BASE, self.public_project._id)
def tearDown(self):
super(TestNodeLogList, self).tearDown()
NodeLog.remove()
def test_add_tag(self):
user_auth = Auth(self.user)
self.public_project.add_tag("Jeff Spies", auth=user_auth)
assert_equal("tag_added", self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(res.json['data'][API_LATEST]['attributes']['action'], 'tag_added')
assert_equal("Jeff Spies", self.public_project.logs[OSF_LATEST].params['tag'])
def test_remove_tag(self):
user_auth = Auth(self.user)
self.public_project.add_tag("Jeff Spies", auth=user_auth)
assert_equal("tag_added", self.public_project.logs[OSF_LATEST].action)
self.public_project.remove_tag("Jeff Spies", auth=self.user_auth)
assert_equal("tag_removed", self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(res.json['data'][API_LATEST]['attributes']['action'], 'tag_removed')
assert_equal("Jeff Spies", self.public_project.logs[OSF_LATEST].params['tag'])
def test_project_created(self):
res = self.app.get(self.public_url)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(self.public_project.logs[OSF_FIRST].action, "project_created")
assert_equal(self.public_project.logs[OSF_FIRST].action,res.json['data'][API_LATEST]['attributes']['action'])
def test_log_create_on_public_project(self):
res = self.app.get(self.public_url)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_datetime_equal(parse_date(res.json['data'][API_FIRST]['attributes']['date']),
self.public_project.logs[OSF_FIRST].date)
assert_equal(res.json['data'][API_FIRST]['attributes']['action'], self.public_project.logs[OSF_FIRST].action)
def test_log_create_on_private_project(self):
res = self.app.get(self.private_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_datetime_equal(datetime.datetime.strptime(res.json['data'][API_FIRST]['attributes']['date'], "%Y-%m-%dT%H:%M:%S.%f"),
self.private_project.logs[OSF_FIRST].date)
assert_equal(res.json['data'][API_FIRST]['attributes']['action'], self.private_project.logs[OSF_FIRST].action)
def test_add_addon(self):
self.public_project.add_addon('github', auth=self.user_auth)
assert_equal('addon_added', self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(res.json['data'][API_LATEST]['attributes']['action'], 'addon_added')
def test_project_add_remove_contributor(self):
self.public_project.add_contributor(self.contrib, auth=self.user_auth)
assert_equal('contributor_added', self.public_project.logs[OSF_LATEST].action)
self.public_project.remove_contributor(self.contrib, auth=self.user_auth)
assert_equal('contributor_removed', self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(res.json['data'][API_LATEST]['attributes']['action'], 'contributor_removed')
assert_equal(res.json['data'][1]['attributes']['action'], 'contributor_added')
def test_remove_addon(self):
self.public_project.add_addon('github', auth=self.user_auth)
assert_equal('addon_added', self.public_project.logs[OSF_LATEST].action)
self.public_project.delete_addon('github', auth=self.user_auth)
assert_equal('addon_removed', self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
assert_equal(res.json['data'][API_LATEST]['attributes']['action'], 'addon_removed')
def test_add_pointer(self):
self.public_project.add_pointer(self.pointer, auth=Auth(self.user), save=True)
assert_equal('pointer_created', self.public_project.logs[OSF_LATEST].action)
res = self.app.get(self.public_url, auth=self.user.auth)
assert_equal(res.status_code, 200)
assert_equal(len(res.json['data']), len(self.public_project.logs))
#.........这里部分代码省略.........
示例2: TestPublicNodes
# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import remove_tag [as 别名]
class TestPublicNodes(SearchTestCase):
def setUp(self):
super(TestPublicNodes, self).setUp()
self.user = UserFactory(usename='Doug Bogie')
self.title = 'Red Special'
self.consolidate_auth = Auth(user=self.user)
self.project = ProjectFactory(
title=self.title,
creator=self.user,
is_public=True,
)
self.component = NodeFactory(
parent=self.project,
title=self.title,
creator=self.user,
is_public=True
)
self.registration = ProjectFactory(
title=self.title,
creator=self.user,
is_public=True,
is_registration=True
)
def test_make_private(self):
"""Make project public, then private, and verify that it is not present
in search.
"""
self.project.set_privacy('private')
docs = query('category:project AND ' + self.title)['results']
assert_equal(len(docs), 0)
self.component.set_privacy('private')
docs = query('category:component AND ' + self.title)['results']
assert_equal(len(docs), 0)
self.registration.set_privacy('private')
docs = query('category:registration AND ' + self.title)['results']
assert_equal(len(docs), 0)
def test_public_parent_title(self):
self.project.set_title('hello & world', self.consolidate_auth)
self.project.save()
docs = query('category:component AND ' + self.title)['results']
assert_equal(len(docs), 1)
assert_equal(docs[0]['parent_title'], 'hello & world')
assert_true(docs[0]['parent_url'])
def test_make_parent_private(self):
"""Make parent of component, public, then private, and verify that the
component still appears but doesn't link to the parent in search.
"""
self.project.set_privacy('private')
docs = query('category:component AND ' + self.title)['results']
assert_equal(len(docs), 1)
assert_equal(docs[0]['parent_title'], '-- private project --')
assert_false(docs[0]['parent_url'])
def test_delete_project(self):
"""
"""
self.component.remove_node(self.consolidate_auth)
docs = query('category:component AND ' + self.title)['results']
assert_equal(len(docs), 0)
self.project.remove_node(self.consolidate_auth)
docs = query('category:project AND ' + self.title)['results']
assert_equal(len(docs), 0)
def test_change_title(self):
"""
"""
title_original = self.project.title
self.project.set_title(
'Blue Ordinary', self.consolidate_auth, save=True)
docs = query('category:project AND ' + title_original)['results']
assert_equal(len(docs), 0)
docs = query('category:project AND ' + self.project.title)['results']
assert_equal(len(docs), 1)
def test_add_tags(self):
tags = ['stonecoldcrazy', 'just a poor boy', 'from-a-poor-family']
for tag in tags:
docs = query('tags:"{}"'.format(tag))['results']
assert_equal(len(docs), 0)
self.project.add_tag(tag, self.consolidate_auth, save=True)
for tag in tags:
docs = query('tags:"{}"'.format(tag))['results']
assert_equal(len(docs), 1)
def test_remove_tag(self):
tags = ['stonecoldcrazy', 'just a poor boy', 'from-a-poor-family']
#.........这里部分代码省略.........
示例3: TestPublicNodes
# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import remove_tag [as 别名]
class TestPublicNodes(SearchTestCase):
def setUp(self):
super(TestPublicNodes, self).setUp()
self.user = UserFactory(usename="Doug Bogie")
self.title = "Red Special"
self.consolidate_auth = Auth(user=self.user)
self.project = ProjectFactory(title=self.title, creator=self.user, is_public=True)
self.component = NodeFactory(parent=self.project, title=self.title, creator=self.user, is_public=True)
self.registration = ProjectFactory(title=self.title, creator=self.user, is_public=True, is_registration=True)
def test_make_private(self):
"""Make project public, then private, and verify that it is not present
in search.
"""
self.project.set_privacy("private")
docs = query("category:project AND " + self.title)["results"]
assert_equal(len(docs), 0)
self.component.set_privacy("private")
docs = query("category:component AND " + self.title)["results"]
assert_equal(len(docs), 0)
self.registration.set_privacy("private")
docs = query("category:registration AND " + self.title)["results"]
assert_equal(len(docs), 0)
def test_public_parent_title(self):
self.project.set_title("hello & world", self.consolidate_auth)
self.project.save()
docs = query("category:component AND " + self.title)["results"]
assert_equal(len(docs), 1)
assert_equal(docs[0]["parent_title"], "hello & world")
assert_true(docs[0]["parent_url"])
def test_make_parent_private(self):
"""Make parent of component, public, then private, and verify that the
component still appears but doesn't link to the parent in search.
"""
self.project.set_privacy("private")
docs = query("category:component AND " + self.title)["results"]
assert_equal(len(docs), 1)
assert_equal(docs[0]["parent_title"], "-- private project --")
assert_false(docs[0]["parent_url"])
def test_delete_project(self):
"""
"""
self.component.remove_node(self.consolidate_auth)
docs = query("category:component AND " + self.title)["results"]
assert_equal(len(docs), 0)
self.project.remove_node(self.consolidate_auth)
docs = query("category:project AND " + self.title)["results"]
assert_equal(len(docs), 0)
def test_change_title(self):
"""
"""
title_original = self.project.title
self.project.set_title("Blue Ordinary", self.consolidate_auth, save=True)
docs = query("category:project AND " + title_original)["results"]
assert_equal(len(docs), 0)
docs = query("category:project AND " + self.project.title)["results"]
assert_equal(len(docs), 1)
def test_add_tags(self):
tags = ["stonecoldcrazy", "just a poor boy", "from-a-poor-family"]
for tag in tags:
docs = query('tags:"{}"'.format(tag))["results"]
assert_equal(len(docs), 0)
self.project.add_tag(tag, self.consolidate_auth, save=True)
for tag in tags:
docs = query('tags:"{}"'.format(tag))["results"]
assert_equal(len(docs), 1)
def test_remove_tag(self):
tags = ["stonecoldcrazy", "just a poor boy", "from-a-poor-family"]
for tag in tags:
self.project.add_tag(tag, self.consolidate_auth, save=True)
self.project.remove_tag(tag, self.consolidate_auth, save=True)
docs = query('tags:"{}"'.format(tag))["results"]
assert_equal(len(docs), 0)
def test_update_wiki(self):
"""Add text to a wiki page, then verify that project is found when
searching for wiki text.
"""
wiki_content = {"home": "Hammer to fall", "swag": "#YOLO"}
for key, value in wiki_content.items():
docs = query(value)["results"]
assert_equal(len(docs), 0)
#.........这里部分代码省略.........