예제 #1
0
 def test_check_credentials_lead(self):
     """Test checking to see if user is lead for certain team."""
     user = User("USFAS689")
     user.github_id = "IDGithub"
     team = Team("brussels", "team", "id")
     team.add_member(user.github_id)
     team.add_team_lead(user.github_id)
     user.permissions_level = Permissions.team_lead
     self.assertTrue(util.check_permissions(user, team))
예제 #2
0
 def test_handle_delete(self):
     """Test team command delete parser."""
     team = Team("BRS", "brs", "web")
     team.github_team_id = "12345"
     test_user = User("userid")
     test_user.github_id = "1234"
     team.add_team_lead("1234")
     self.db.retrieve.return_value = test_user
     self.db.query.return_value = [team]
     self.assertTupleEqual(self.testcommand.handle("team delete brs", user),
                           (f"Team brs deleted", 200))
     self.db.delete.assert_called_once_with(Team, "12345")
     self.gh.org_delete_team.assert_called_once_with(int("12345"))
예제 #3
0
 def test_handle_lead(self):
     """Test team command lead parser with add and remove options."""
     test_user = User("userid")
     test_user.permissions_level = Permissions.admin
     test_user.github_username = "******"
     team = Team("BRS", "brs", "web")
     team.github_team_id = "githubid"
     other_user = User("anotheruser")
     other_user.github_id = "githubID"
     other_user.github_username = "******"
     self.db.retrieve.side_effect = [test_user, other_user,
                                     test_user, other_user]
     self.db.query.return_value = [team]
     team.add_member("githubID")
     team_before_attach = [team.get_attachment()]
     team.add_team_lead("githubID")
     team_attach = [team.get_attachment()]
     team.discard_member("githubID")
     with self.app.app_context():
         resp, code = self.testcommand.handle("team lead brs ID", user)
         expect = json.loads(jsonify({'attachments': team_attach,
                                      'text': 'User added '
                                              'as team lead to brs'}).data)
         resp = json.loads(resp.data)
         self.assertDictEqual(resp, expect)
         self.assertEqual(code, 200)
         assert team.has_member("githubID")
         self.gh.add_team_member.assert_called_once_with("myuser",
                                                         "githubid")
         self.db.store.assert_called()
         resp, code = self.testcommand.handle("team lead  "
                                              "--remove brs ID", user)
         expect = json.loads(jsonify({'attachments': team_before_attach,
                                      'text': 'User removed as team lead'
                                              ' from brs'}).data)
         resp = json.loads(resp.data)
         self.assertDictEqual(resp, expect)
         self.assertEqual(code, 200)
         assert not team.has_team_lead("githubID")
         self.db.store.assert_called()