Пример #1
0
 def add_user(self, user, identity):
     r = TeamUserRelationship.get(team_id=self.id,
                                  user_id=user.name)
     if not r:
         TeamUserRelationship.create(team_id=self.id,
                                     user_id=user.name,
                                     identity=identity)
         return True
Пример #2
0
    def ttest_at_team(self):  # FIXME
        mention = "test_team"
        team_name = "测试team"
        description = "测试"
        team = Team.add(mention, team_name, description)
        ok_(team.uid == mention)

        content = "@test_team code"
        users = get_mentions_from_text(content)
        # ok_(len(users) == 0)

        team_id = team.id
        user_id = "chengeng"
        identity = 2
        rl = TeamUserRelationship.create(team_id=team_id,
                                         user_id=user_id,
                                         identity=identity)
        ok_(rl.user_id == user_id)

        users = get_mentions_from_text(content)
        ok_(users[0] == user_id)

        rl.delete()

        users = get_mentions_from_text(content)
        ok_(len(users) == 0)

        team.delete()

        users = get_mentions_from_text(content)
        ok_(users[0] == mention)
Пример #3
0
    def test_at_team(self):
        mention = "test_team"
        team_name = "测试team"
        description = "测试"
        team = Team.add(mention, team_name, description)
        ok_(team.uid == mention)

        content = "@test_team code"
        users = get_mentions_from_text(content)
        ok_(len(users) == 0)

        team_id = team.id
        user_id = "chengeng"
        identity = 2
        rl = TeamUserRelationship.create(team_id=team_id,
                                         user_id=user_id,
                                         identity=identity)
        ok_(rl.user_id == user_id)

        users = get_mentions_from_text(content)
        ok_(users[0] == user_id)

        rl.delete()

        users = get_mentions_from_text(content)
        ok_(len(users) == 0)

        team.delete()

        users = get_mentions_from_text(content)
        ok_(users[0] == mention)
Пример #4
0
 def test_add_and_delete_team_user_relationship(self):
     team_id = 1111
     user_id = "chengeng"
     identity = 2
     rl = TeamUserRelationship.create(team_id=team_id,
                                      user_id=user_id,
                                      identity=identity)
     relationship = TeamUserRelationship.get(team_id=team_id,
                                             user_id=user_id)
     ok_(rl.id == relationship.id)
     rl.delete()
Пример #5
0
 def test_add_and_delete_team_user_relationship(self):
     team_id = 1111
     user_id = "chengeng"
     identity = 2
     rl = TeamUserRelationship.create(team_id=team_id,
                                      user_id=user_id,
                                      identity=identity)
     relationship = TeamUserRelationship.get(team_id=team_id,
                                             user_id=user_id)
     ok_(rl.id == relationship.id)
     rl.delete()
Пример #6
0
 def add_member(self, username):
     r = TeamUserRelationship.get(team_id=self.id,
                                  user_id=username)
     if not r:
         r = TeamUserRelationship.create(team_id=self.id,
                                         user_id=username,
                                         identity=TEAM_MEMBER)
         return True
     if r.identity != TEAM_MEMBER:
         r.identity = TEAM_MEMBER
         r.save()
     return True