def test_util_tags_resources_tool_link_project(resource_a, tag_c): resource_tool = TagsResourcesTool(projects=[resource_a.project]) tag_c.project = resource_a.project tag_c.save() assert tag_c.resources.count() == 0 resource_tool.link(tag_c.slug, '**') assert (tag_c.resources.count() == Resource.objects.filter( project=resource_a.project).count())
def test_util_tags_resources_tool_link_project(resource_a, tag_c): resource_tool = TagsResourcesTool(projects=[resource_a.project]) tag_c.project = resource_a.project tag_c.save() assert tag_c.resources.count() == 0 resource_tool.link(tag_c.slug, '*') assert ( tag_c.resources.count() == Resource.objects.filter(project=resource_a.project).count() )
def test_util_tags_resources_tool_link(resource_a, tag_c): resource_tool = TagsResourcesTool() assert tag_c.resources.count() == 0 resource_tool.link(tag_c.slug, '**') assert tag_c.resources.count() == Resource.objects.count() tag_c.resources.remove(*list(tag_c.resources.all())) resource_tool.link(tag_c.slug, resource_a.path) assert tag_c.resources.count() == 1 assert resource_a in tag_c.resources.all()
def test_util_tags_resources_tool_link(resource_a, tag_c): resource_tool = TagsResourcesTool() assert tag_c.resources.count() == 0 resource_tool.link(tag_c.slug, '*') assert tag_c.resources.count() == Resource.objects.count() tag_c.resources.remove(*list(tag_c.resources.all())) resource_tool.link(tag_c.slug, resource_a.path) assert tag_c.resources.count() == 1 assert resource_a in tag_c.resources.all()
def test_util_tags_resources_tool_link_paths(resource_a, tag_c): resource_tool = TagsResourcesTool() assert tag_c.resources.count() == 0 resource_tool.link(tag_c.slug, resources=Resource.objects.values("project", "path")) assert tag_c.resources.count() == Resource.objects.count() tag_c.resources.remove(*list(tag_c.resources.all())) resource_tool.link( tag_c.slug, resources=[dict(project=resource_a.project.pk, path=resource_a.path)]) assert tag_c.resources.count() == 1 assert resource_a in tag_c.resources.all()
def test_util_tags_resources_tool_link_paths(resource_a, tag_c): resource_tool = TagsResourcesTool() assert tag_c.resources.count() == 0 resource_tool.link( tag_c.slug, resources=Resource.objects.values("project", "path") ) assert tag_c.resources.count() == Resource.objects.count() tag_c.resources.remove(*list(tag_c.resources.all())) resource_tool.link( tag_c.slug, resources=[dict(project=resource_a.project.pk, path=resource_a.path)] ) assert tag_c.resources.count() == 1 assert resource_a in tag_c.resources.all()
def test_util_tags_resources_tool_link_bad(resource_a, tag_c, project_b): resource_tool = TagsResourcesTool() tag_c.project = project_b tag_c.save() with pytest.raises(InvalidProjectError): resource_tool.link(tag_c.slug, resources=[{ 'project': resource_a.project.pk, 'path': resource_a.path, }]) with pytest.raises(InvalidProjectError): resource_tool.link( tag_c.slug, resources=[{ 'project': resource_a.project.pk, 'path': resource_a.path, }] )
def test_util_tags_resources_tool_link_bad(resource0, tagX, project1): resource_tool = TagsResourcesTool() tagX.project = project1 tagX.save() with pytest.raises(InvalidProjectError): resource_tool.link(tagX.slug, resource0.path) with pytest.raises(InvalidProjectError): resource_tool.link(tagX.slug, "*") with pytest.raises(InvalidProjectError): resource_tool.link(tagX.slug, resources=[ dict(project=resource0.project.id, path=resource0.path) ])
def test_util_tags_resources_tool_link_bad(resource_a, tag_c, project_b): resource_tool = TagsResourcesTool() tag_c.project = project_b tag_c.save() with pytest.raises(InvalidProjectError): resource_tool.link(tag_c.slug, resource_a.path) with pytest.raises(InvalidProjectError): resource_tool.link(tag_c.slug, "*") with pytest.raises(InvalidProjectError): resource_tool.link( tag_c.slug, resources=[{ 'project': resource_a.project.id, 'path': resource_a.path, }] )
def test_util_tags_resources_tool_link_project(resource0, tagX): resource_tool = TagsResourcesTool(projects=[resource0.project]) assert tagX.resources.count() == 0 resource_tool.link(tagX.slug, '*') assert (tagX.resources.count() == Resource.objects.filter( project=resource0.project).count())