当前位置: 首页>>代码示例>>Python>>正文


Python json.loads函数代码示例

本文整理汇总了Python中taiga.base.utils.json.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_project_list_with_discover_mode_enabled

def test_project_list_with_discover_mode_enabled(client, data):
    url = "{}?{}".format(reverse('projects-list'), "discover_mode=true")

    response = client.get(url)
    projects_data = json.loads(response.content.decode('utf-8'))
    assert len(projects_data) == 2
    assert response.status_code == 200

    client.login(data.registered_user)

    response = client.get(url)
    projects_data = json.loads(response.content.decode('utf-8'))
    assert len(projects_data) == 2
    assert response.status_code == 200

    client.login(data.project_member_with_perms)

    response = client.get(url)
    projects_data = json.loads(response.content.decode('utf-8'))
    assert len(projects_data) == 2
    assert response.status_code == 200

    client.login(data.project_owner)

    response = client.get(url)
    projects_data = json.loads(response.content.decode('utf-8'))
    assert len(projects_data) == 2
    assert response.status_code == 200
开发者ID:SKOx0,项目名称:taiga-back,代码行数:28,代码来源:test_projects_resource.py

示例2: test_user_list

def test_user_list(client, data):
    url = reverse("users-list")

    response = client.get(url)
    users_data = json.loads(response.content.decode("utf-8"))
    assert len(users_data) == 0
    assert response.status_code == 200

    client.login(data.registered_user)

    response = client.get(url)
    users_data = json.loads(response.content.decode("utf-8"))
    assert len(users_data) == 1
    assert response.status_code == 200

    client.login(data.other_user)

    response = client.get(url)
    users_data = json.loads(response.content.decode("utf-8"))
    assert len(users_data) == 1
    assert response.status_code == 200

    client.login(data.superuser)

    response = client.get(url)
    users_data = json.loads(response.content.decode("utf-8"))
    assert len(users_data) == 3
    assert response.status_code == 200
开发者ID:niibruce,项目名称:taiga-back,代码行数:28,代码来源:test_users_resources.py

示例3: test_projects_user_order

def test_projects_user_order(client):
    user = f.UserFactory.create(is_superuser=True)
    project_1 = f.create_project()
    role_1 = f.RoleFactory(project=project_1)
    f.MembershipFactory(user=user, project=project_1, is_owner=True, role=role_1, user_order=2)

    project_2 = f.create_project()
    role_2 = f.RoleFactory(project=project_2)
    f.MembershipFactory(user=user, project=project_2, is_owner=True, role=role_2, user_order=1)

    client.login(user)
    #Testing default id order
    url = reverse("projects-list")
    url = "%s?member=%s" % (url, user.id)
    response = client.json.get(url)
    response_content = json.loads(response.content.decode("utf-8"))
    assert response.status_code == 200
    assert(response_content[0]["id"] == project_1.id)

    #Testing user order
    url = reverse("projects-list")
    url = "%s?member=%s&order_by=memberships__user_order" % (url, user.id)
    response = client.json.get(url)
    response_content = json.loads(response.content.decode("utf-8"))
    assert response.status_code == 200
    assert(response_content[0]["id"] == project_2.id)
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:26,代码来源:test_projects.py

示例4: test_resolver_list

def test_resolver_list(client, data):
    url = reverse("resolver-list")

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner,
    ]

    results = helper_test_http_method(client, "get", "{}?project=public".format(url), None, users)
    assert results == [200, 200, 200, 200, 200]
    results = helper_test_http_method(client, "get", "{}?project=private1".format(url), None, users)
    assert results == [200, 200, 200, 200, 200]
    results = helper_test_http_method(client, "get", "{}?project=private2".format(url), None, users)
    assert results == [401, 403, 403, 200, 200]

    client.login(data.other_user)
    response = client.get("{}?project=private2&us=1&task=2&issue=3&milestone=4".format(url))
    assert json.loads(response.content.decode("utf-8")) == {"project": data.private_project2.pk}

    client.login(data.project_owner)
    response = client.get("{}?project=private2&us=1&task=2&issue=3&milestone=4".format(url))
    assert json.loads(response.content.decode("utf-8")) == {
        "project": data.private_project2.pk,
        "us": 1,
        "task": 1,
        "issue": 1,
        "milestone": data.milestone.pk,
    }
开发者ID:epintor,项目名称:taiga-back,代码行数:31,代码来源:test_resolver_resources.py

示例5: test_task_list

def test_task_list(client, data):
    url = reverse("tasks-list")

    response = client.get(url)
    tasks_data = json.loads(response.content.decode("utf-8"))
    assert len(tasks_data) == 2
    assert response.status_code == 200

    client.login(data.registered_user)

    response = client.get(url)
    tasks_data = json.loads(response.content.decode("utf-8"))
    assert len(tasks_data) == 2
    assert response.status_code == 200

    client.login(data.project_member_with_perms)

    response = client.get(url)
    tasks_data = json.loads(response.content.decode("utf-8"))
    assert len(tasks_data) == 3
    assert response.status_code == 200

    client.login(data.project_owner)

    response = client.get(url)
    tasks_data = json.loads(response.content.decode("utf-8"))
    assert len(tasks_data) == 3
    assert response.status_code == 200
开发者ID:bdang2012,项目名称:taiga-back,代码行数:28,代码来源:test_tasks_resources.py

示例6: test_epic_related_userstories_list

def test_epic_related_userstories_list(client, data):
    url = reverse('epics-related-userstories-list', args=[data.public_epic.pk])
    response = client.get(url)
    related_uss_data = json.loads(response.content.decode('utf-8'))
    assert len(related_uss_data) == 1
    assert response.status_code == 200

    client.login(data.registered_user)

    url = reverse('epics-related-userstories-list', args=[data.private_epic1.pk])
    response = client.get(url)
    related_uss_data = json.loads(response.content.decode('utf-8'))
    assert len(related_uss_data) == 1
    assert response.status_code == 200

    client.login(data.project_member_with_perms)

    url = reverse('epics-related-userstories-list', args=[data.private_epic2.pk])
    response = client.get(url)
    related_uss_data = json.loads(response.content.decode('utf-8'))
    assert len(related_uss_data) == 1
    assert response.status_code == 200

    client.login(data.project_owner)

    url = reverse('epics-related-userstories-list', args=[data.blocked_epic.pk])
    response = client.get(url)
    related_uss_data = json.loads(response.content.decode('utf-8'))
    assert len(related_uss_data) == 1
    assert response.status_code == 200
开发者ID:aminadha,项目名称:taiga-back,代码行数:30,代码来源:test_epics_related_userstories_resources.py

示例7: test_wiki_link_list

def test_wiki_link_list(client, data):
    url = reverse('wiki-links-list')

    response = client.get(url)
    wiki_links_data = json.loads(response.content.decode('utf-8'))
    assert len(wiki_links_data) == 2
    assert response.status_code == 200

    client.login(data.registered_user)

    response = client.get(url)
    wiki_links_data = json.loads(response.content.decode('utf-8'))
    assert len(wiki_links_data) == 2
    assert response.status_code == 200

    client.login(data.project_member_with_perms)

    response = client.get(url)
    wiki_links_data = json.loads(response.content.decode('utf-8'))
    assert len(wiki_links_data) == 3
    assert response.status_code == 200

    client.login(data.project_owner)

    response = client.get(url)
    wiki_links_data = json.loads(response.content.decode('utf-8'))
    assert len(wiki_links_data) == 3
    assert response.status_code == 200
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:28,代码来源:test_wiki_resources.py

示例8: test_invalid_issue_import_with_bad_choices

def test_invalid_issue_import_with_bad_choices(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    f.MembershipFactory(project=project, user=user, is_owner=True)
    project.default_issue_type = f.IssueTypeFactory.create(project=project)
    project.default_issue_status = f.IssueStatusFactory.create(project=project)
    project.default_severity = f.SeverityFactory.create(project=project)
    project.default_priority = f.PriorityFactory.create(project=project)
    project.save()
    client.login(user)

    url = reverse("importer-issue", args=[project.pk])
    data = {
        "subject": "Imported issue",
        "description": "Imported issue",
        "status": "Not valid"
    }

    response = client.post(url, json.dumps(data), content_type="application/json")
    assert response.status_code == 400
    response_data = json.loads(response.content.decode("utf-8"))
    assert len(response_data) == 1

    url = reverse("importer-issue", args=[project.pk])
    data = {
        "subject": "Imported issue",
        "description": "Imported issue",
        "priority": "Not valid"
    }

    response = client.post(url, json.dumps(data), content_type="application/json")
    assert response.status_code == 400
    response_data = json.loads(response.content.decode("utf-8"))
    assert len(response_data) == 1

    url = reverse("importer-issue", args=[project.pk])
    data = {
        "subject": "Imported issue",
        "description": "Imported issue",
        "severity": "Not valid"
    }

    response = client.post(url, json.dumps(data), content_type="application/json")
    assert response.status_code == 400
    response_data = json.loads(response.content.decode("utf-8"))
    assert len(response_data) == 1

    url = reverse("importer-issue", args=[project.pk])
    data = {
        "subject": "Imported issue",
        "description": "Imported issue",
        "type": "Not valid"
    }

    response = client.post(url, json.dumps(data), content_type="application/json")
    assert response.status_code == 400
    response_data = json.loads(response.content.decode("utf-8"))
    assert len(response_data) == 1
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:58,代码来源:test_importer_api.py

示例9: test_valid_wiki_link_import

def test_valid_wiki_link_import(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    f.MembershipFactory(project=project, user=user, is_owner=True)
    client.login(user)

    url = reverse("importer-wiki-link", args=[project.pk])
    data = {
        "title": "Imported wiki_link",
        "href": "imported-wiki-link",
    }

    response = client.post(url, json.dumps(data), content_type="application/json")
    assert response.status_code == 201
    json.loads(response.content.decode("utf-8"))
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:15,代码来源:test_importer_api.py

示例10: test_import_epic_with_user_stories

def test_import_epic_with_user_stories(client):
    project = f.ProjectFactory()
    project.default_points = f.PointsFactory.create(project=project)
    project.default_issue_type = f.IssueTypeFactory.create(project=project)
    project.default_issue_status = f.IssueStatusFactory.create(project=project)
    project.default_epic_status = f.EpicStatusFactory.create(project=project)
    project.default_us_status = f.UserStoryStatusFactory.create(project=project)
    project.default_task_status = f.TaskStatusFactory.create(project=project)
    project.default_priority = f.PriorityFactory.create(project=project)
    project.default_severity = f.SeverityFactory.create(project=project)

    epic = f.EpicFactory.create(subject="test epic export", project=project, status=project.default_epic_status)
    user_story = f.UserStoryFactory.create(project=project, status=project.default_us_status, milestone=None)
    f.RelatedUserStory.create(epic=epic, user_story=user_story, order=55)
    output = io.BytesIO()
    render_project(user_story.project, output)
    project_data = json.loads(output.getvalue())

    epic.project.delete()

    project = store_project_from_dict(project_data)
    assert project.epics.count() == 1
    assert project.epics.first().ref == epic.ref

    assert project.epics.first().user_stories.count() == 1
    related_userstory = project.epics.first().relateduserstory_set.first()
    assert related_userstory.user_story.ref == user_story.ref
    assert related_userstory.order == 55
    assert related_userstory.epic.ref == epic.ref
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:29,代码来源:test_import.py

示例11: test_export_issue_finish_date

def test_export_issue_finish_date(client):
    issue = f.IssueFactory.create(finished_date="2014-10-22")
    output = io.StringIO()
    render_project(issue.project, output)
    project_data = json.loads(output.getvalue())
    finish_date = project_data["issues"][0]["finished_date"]
    assert finish_date == "2014-10-22T00:00:00+0000"
开发者ID:SKOx0,项目名称:taiga-back,代码行数:7,代码来源:test_export.py

示例12: handle

    def handle(self, *args, **options):
        dump_file_path = options["dump_file"]
        owner_email = options["owner_email"]
        overwrite = options["overwrite"]

        data = json.loads(open(dump_file_path, 'r').read())
        try:
            with transaction.atomic():
                if overwrite:
                    receivers_back = signals.post_delete.receivers
                    signals.post_delete.receivers = []
                    try:
                        proj = Project.objects.get(slug=data.get("slug", "not a slug"))
                        proj.tasks.all().delete()
                        proj.user_stories.all().delete()
                        proj.issues.all().delete()
                        proj.memberships.all().delete()
                        proj.roles.all().delete()
                        proj.delete()
                    except Project.DoesNotExist:
                        pass
                    signals.post_delete.receivers = receivers_back

                user = User.objects.get(email=owner_email)
                services.store_project_from_dict(data, user)
        except err.TaigaImportError as e:
            if e.project:
                e.project.delete_related_content()
                e.project.delete()

            print("ERROR:", end=" ")
            print(e.message)
            print(json.dumps(e.errors, indent=4))
开发者ID:0-T-0,项目名称:taiga-back,代码行数:33,代码来源:load_dump.py

示例13: test_valid_concurrent_save_for_issue_different_versions

def test_valid_concurrent_save_for_issue_different_versions(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    membership = f.MembershipFactory.create(project=project, user=user, is_owner=True)
    client.login(user)

    mock_path = "taiga.projects.issues.api.IssueViewSet.pre_conditions_on_save"
    with patch(mock_path) as m:
        url = reverse("issues-list")
        data = {"subject": "test",
                      "project": project.id,
                      "status": f.IssueStatusFactory.create(project=project).id,
                      "severity": f.SeverityFactory.create(project=project).id,
                      "type": f.IssueTypeFactory.create(project=project).id,
                      "priority": f.PriorityFactory.create(project=project).id}
        response = client.json.post(url, json.dumps(data))
        assert response.status_code == 201, response.content

        issue_id = json.loads(response.content)["id"]
        url = reverse("issues-detail", args=(issue_id,))
        data = {"version":1, "subject": "test 1"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200

        data = {"version":2, "subject": "test 2"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:27,代码来源:test_occ.py

示例14: test_invalid_concurrent_save_for_us

def test_invalid_concurrent_save_for_us(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    membership = f.MembershipFactory.create(project=project, user=user, is_owner=True)
    userstory = f.UserStoryFactory.create(version=10, project=project)
    client.login(user)

    mock_path = "taiga.projects.userstories.api.UserStoryViewSet.pre_conditions_on_save"
    with patch(mock_path) as m:
        url = reverse("userstories-list")
        data = {"subject": "test",
                      "project": project.id,
                      "status": f.UserStoryStatusFactory.create(project=project).id}
        response = client.json.post(url, json.dumps(data))
        assert response.status_code == 201

        userstory_id = json.loads(response.content)["id"]
        url = reverse("userstories-detail", args=(userstory_id,))
        data = {"version":1, "subject": "test 1"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200

        data = {"version":1, "subject": "test 2"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 400
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:25,代码来源:test_occ.py

示例15: handle

    def handle(self, *args, **options):
        data = json.loads(open(args[0], 'r').read())
        try:
            with transaction.atomic():
                if options["overwrite"]:
                    receivers_back = signals.post_delete.receivers
                    signals.post_delete.receivers = []
                    try:
                        proj = Project.objects.get(slug=data.get("slug", "not a slug"))
                        proj.tasks.all().delete()
                        proj.user_stories.all().delete()
                        proj.issues.all().delete()
                        proj.memberships.all().delete()
                        proj.roles.all().delete()
                        proj.delete()
                    except Project.DoesNotExist:
                        pass
                    signals.post_delete.receivers = receivers_back

                user = User.objects.get(email=args[1])
                dict_to_project(data, user)
        except TaigaImportError as e:
            print("ERROR:", end=" ")
            print(e.message)
            print(get_errors())
开发者ID:OneOaaS,项目名称:taiga-back,代码行数:25,代码来源:load_dump.py


注:本文中的taiga.base.utils.json.loads函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。