예제 #1
0
def deleteGroup(groupName):
    """Delete a group from the database
                Args:
                        Groupname - String - the name of the group
                Return:
                        None 
        """
    Group.deleteGroup(groupName)
예제 #2
0
def createGroup(name, created_by):
    """Creates a group
        Args:
                name - String - Name of the group
                created_by  -String  - Usename of the group creator
        Return:
                None
        Rasies:

        """
    Group.createGroup(name, created_by)
    def test_Group_created_by(self):
        """
	Tests the Group_created_by function to see if it returns the correct username
        """
        with project.app.app_context():
            self.assertEqual(
                Group.Group_created_by('TestGroup')[0], 'adminTest2')
예제 #4
0
def getAGroupInfo(group_id):
    """Gets the id, name, created_by attributes of a group
                Args:
                        Groupid - int - the group id number
                Return:
                        id, name, created_by of the group 
        """
    return Group.getAGroupInfo(group_id)
예제 #5
0
def Group_created_by(Groupname):
    """Gets the name of the user that created the group
                Args:
                        Groupname - String - the name of the group
                Return:
                        Usename of the group creator 
        """
    return Group.Group_created_by(Groupname)
 def setUp(self):
     """Setup new databse for test methods
        Populate the database with at least one record per table for testing
     """
     self.db_fd, project.app.config['DATABASE'] = tempfile.mkstemp()
     project.app.testing = True
     self.app = project.app.test_client()
     with project.app.app_context():
         db.Database().create_tables()
         user.createUser('adminTest', 'tcg1134', '', '')
         user.createUser('adminTest2', 'gct2334', '', '')
         Group.createGroup('TestGroup', 'adminTest2')
         topic.insertTopic('TestTopic', 'adminTest2', '1')
         post.insertPost(1, 'adminTest2', 'TestPost', 'Some random text')
         subscription.addToSub(1, 1)
         notification.sendNotif("post", 1)
         Votes.upvote(1, 1)
예제 #7
0
def getGroups():
    """Gets the all the groups in the database
                Args:
                        None
                Return:
                        List of groups created 
                        
        """
    return Group.getGroups()
    def test_getGroupTopics(self):
        """
	Tests the getGroupTopics function to see if it returns the correct list of topics
        """
        with project.app.app_context():
            allTopics = []
            for atopic in Group.getGroupTopics(1):
                allTopics.append(list(atopic))
            self.assertEqual(allTopics, [[1, 'TestTopic', 1]])
예제 #9
0
def getGroupId(groupName):
    """This function gets a group id number
    
                args:
                        name    String      the group name

                Return:
                        GroupId     Int     the group id number
        """
    return Group.getGroupId(str(groupName))
예제 #10
0
def AddMemberToGroup(group_id, user_id):
    """This function adds a user to a group

                args:
                        group_id    Int     the group id number
                        user_id     Int     the user id number
    
                Return:
                        None
        """
    Group.AddMemberToGroup(group_id, user_id)
예제 #11
0
def getGroupMembers(group_id):
    """This function gets the user_id of a members of a particular group

                args:
                        group_id    int     the group id number

                Return:
                        members     List    A list containing (membership_id, user-id, group_id) attributes of a user
    
    """
    return Group.getGroupMembers(group_id)
    def test_getGroupId(self):
        """
	Tests the getGroupId function to see if it returns the correct id
        """
        with project.app.app_context():
            self.assertEqual(Group.getGroupId('TestGroup')[0], 1)