Exemplo n.º 1
0
    def setUp(self):
        user = create_new_user()

        self.register_user_url(user)

        headers = {"Authorization": "Bearer {}".format(user.id)}
        self.user_resp = requests.get(api_user_url(user.id), headers=headers).json()["data"]

        node = create_new_top_level_node(user)
        self.register_user_nodes_url(user)

        self.node_resp = requests.get(self.user_resp["links"]["nodes"]["relation"], headers=headers).json()["data"][0]

        provider_folder = create_provider_folder(node)
        self.register_node_providers_url(node)
        self.folder_provider_resp = requests.get(self.node_resp["links"]["files"]["related"], headers=headers).json()[
            "data"
        ][0]

        folder1 = create_new_folder(provider_folder)
        folder2 = create_new_folder(provider_folder)
        file = create_new_file(folder2)
        self.register_folder_children_url(provider_folder)
        self.register_folder_children_url(folder1)
        self.register_folder_children_url(folder2)
        # http://localhost:8000/v2/nodes/1/files?path=/&provider=osfstorage
        self.folder2_resp = requests.get(self.folder_provider_resp["links"]["related"], headers=headers).json()["data"][
            1
        ]

        self.file_resp = requests.get(self.folder2_resp["links"]["related"], headers=headers).json()["data"][0]
    def setUp(self):
        user = create_new_user()

        self.register_user_url(user)

        headers = {'Authorization':'Bearer {}'.format(user.id)}
        self.user_resp = requests.get(api_user_url(user.id), headers=headers).json()['data']

        node = create_new_top_level_node(user)
        self.register_user_nodes_url(user)

        self.node_resp = requests.get(self.user_resp['links']['nodes']['relation'], headers=headers).json()['data'][0]

        provider_folder = create_provider_folder(node)
        self.register_node_providers_url(node)
        self.folder_provider_resp = requests.get(self.node_resp['links']['files']['related'], headers=headers).json()['data'][0]

        folder1 = create_new_folder(provider_folder)
        folder2 = create_new_folder(provider_folder)
        file = create_new_file(folder2)
        self.register_folder_children_url(provider_folder)
        self.register_folder_children_url(folder1)
        self.register_folder_children_url(folder2)
        # http://localhost:8000/v2/nodes/1/files?path=/&provider=osfstorage
        self.folder2_resp =requests.get(self.folder_provider_resp['links']['related'], headers=headers).json()['data'][1]


        self.file_resp = requests.get(self.folder2_resp['links']['related'], headers=headers).json()['data'][0]
 def register_user_url(self, user):
     httpretty.register_uri(
         httpretty.GET,
         api_user_url(user.id),
         body=get_user,
         content_type="application/json"
     )
Exemplo n.º 4
0
 def as_dict(self):
     return {
             "id": self.id,
             "fullname": self.fullname,
             "given_name": self.fullname,
             "middle_name": "",
             "family_name": "",
             "suffix": "",
             "date_registered": "2015-07-06T17:51:22.833000",
             "gravatar_url": "https://secure.gravatar.com/avatar/7241b93c02e7d393e5f118511880734a?d=identicon&size=40",
             "employment_institutions": [],
             "educational_institutions": [],
             "social_accounts": {},
             "links": {
                 "nodes": {
                     "relation": 'http://localhost:8000/v2/users/{}/nodes/'.format(self.id)
                 },
                 "html": 'http://localhost:5000/5bqt9/',
                 "self": api_user_url(self.id)
             },
             "type": "users"
         }
Exemplo n.º 5
0
 def as_dict(self):
     return {
         "id": self.id,
         "fullname": self.fullname,
         "given_name": self.fullname,
         "middle_name": "",
         "family_name": "",
         "suffix": "",
         "date_registered": "2015-07-06T17:51:22.833000",
         "gravatar_url":
         "https://secure.gravatar.com/avatar/7241b93c02e7d393e5f118511880734a?d=identicon&size=40",
         "employment_institutions": [],
         "educational_institutions": [],
         "social_accounts": {},
         "links": {
             "nodes": {
                 "relation":
                 'http://localhost:8000/v2/users/{}/nodes/'.format(self.id)
             },
             "html": 'http://localhost:5000/5bqt9/',
             "self": api_user_url(self.id)
         },
         "type": "users"
     }
Exemplo n.º 6
0
 def register_user_url(self, user):
     httpretty.register_uri(httpretty.GET, api_user_url(user.id), body=get_user, content_type="application/json")