Exemplo n.º 1
0
 def setUp(self):
     super(TestMigrateDeletedWikis, self).setUp()
     self.user = UserFactory()
     self.auth = Auth(user=self.user)
     self.project = ProjectFactory(creator=self.user)
     # Update home wiki (which can't be deleted) an a second wiki
     self.project.update_node_wiki('home', 'Hello world', self.auth)
     self.project.update_node_wiki('second', 'Hola mundo', self.auth)
     self.project.update_node_wiki('second', 'Hola mundo 2', self.auth)
     self.versions = self.project.wiki_pages_versions
     self.current = self.project.wiki_pages_current
Exemplo n.º 2
0
 def test_more_than_one_projects_in_common(self):
     project1 = ProjectFactory(creator=self.user_one)
     project1.add_contributor(contributor=self.user_two,
                              permissions=CREATOR_PERMISSIONS,
                              auth=Auth(user=self.user_one))
     project1.save()
     project2 = ProjectFactory(creator=self.user_one)
     project2.add_contributor(contributor=self.user_two,
                              permissions=CREATOR_PERMISSIONS,
                              auth=Auth(user=self.user_one))
     project2.save()
     url = "/{}users/?show_projects_in_common=true".format(API_BASE)
     res = self.app.get(url, auth=self.user_two.auth)
     user_json = res.json['data']
     for user in user_json:
         if user['id'] == self.user_one._id or user[
                 'id'] == self.user_two._id:
             meta = user['relationships']['nodes']['links']['related'][
                 'meta']
             assert_in('projects_in_common', meta)
             assert_equal(meta['projects_in_common'], 2)
Exemplo n.º 3
0
 def test_users_projects_in_common_with_embed_without_right_query(self):
     project = ProjectFactory(creator=self.user_one)
     project.add_contributor(contributor=self.user_two,
                             permissions=CREATOR_PERMISSIONS,
                             auth=Auth(user=self.user_one))
     project.save()
     url = "/{}users/{}/nodes/?embed=contributors".format(
         API_BASE, self.user_two._id)
     res = self.app.get(url, auth=self.user_two.auth)
     user_json = res.json['data'][0]['embeds']['contributors']['data']
     for user in user_json:
         meta = user['embeds']['users']['data']['relationships']['nodes'][
             'links']['related']['meta']
         assert_not_in('projects_in_common', meta)
Exemplo n.º 4
0
 def test_users_projects_in_common_exclude_deleted_projects(self):
     project_list = []
     for x in range(1, 10):
         project = ProjectFactory(creator=self.user_one)
         project.add_contributor(contributor=self.user_two,
                                 permissions=CREATOR_PERMISSIONS,
                                 auth=Auth(user=self.user_one))
         project.save()
         project_list.append(project)
     for x in range(1, 5):
         project = project_list[x]
         project.reload()
         project.remove_node(auth=Auth(user=self.user_one))
         project.save()
     url = "/{}users/{}/nodes/?embed=contributors&show_projects_in_common=true".format(
         API_BASE, self.user_two._id)
     res = self.app.get(url, auth=self.user_two.auth)
     user_json = res.json['data'][0]['embeds']['contributors']['data']
     for user in user_json:
         meta = user['embeds']['users']['data']['relationships']['nodes'][
             'links']['related']['meta']
         assert_in('projects_in_common', meta)
         assert_equal(meta['projects_in_common'], 5)