Fix missing to_dict and import in robots model
Also adds a test to catch this issue
This commit is contained in:
parent
b37885d1e9
commit
854155fe82
3 changed files with 15 additions and 5 deletions
|
@ -25,6 +25,11 @@ class Team(namedtuple('Team', ['name', 'avatar'])):
|
|||
:type name: string
|
||||
:type avatar: {string -> string}
|
||||
"""
|
||||
def to_dict(self):
|
||||
return {
|
||||
'name': self.name,
|
||||
'avatar': self.avatar,
|
||||
}
|
||||
|
||||
|
||||
class RobotWithPermissions(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from app import avatar
|
||||
from data import model
|
||||
from data.database import User, FederatedLogin, Team, Repository
|
||||
from endpoints.api.robot_models_interface import RobotInterface, Robot, RobotWithPermissions, Permission
|
||||
from data.database import User, FederatedLogin, Team as TeamTable, Repository
|
||||
from endpoints.api.robot_models_interface import (RobotInterface, Robot, RobotWithPermissions, Team,
|
||||
Permission)
|
||||
|
||||
|
||||
class RobotPreOCIModel(RobotInterface):
|
||||
|
@ -31,7 +32,7 @@ class RobotPreOCIModel(RobotInterface):
|
|||
})
|
||||
robots[robot_name] = Robot(robot_dict['name'], robot_dict['token'])
|
||||
if include_permissions:
|
||||
team_name = robot_tuple.get(Team.name)
|
||||
team_name = robot_tuple.get(TeamTable.name)
|
||||
repository_name = robot_tuple.get(Repository.name)
|
||||
|
||||
if team_name is not None:
|
||||
|
|
|
@ -3234,10 +3234,11 @@ class TestUserRobots(ApiTestCase):
|
|||
|
||||
|
||||
class TestOrgRobots(ApiTestCase):
|
||||
def getRobotNames(self):
|
||||
def getRobotNames(self, include_permissions=False):
|
||||
params = dict(orgname=ORGANIZATION, permissions=include_permissions)
|
||||
return [
|
||||
r['name']
|
||||
for r in self.getJsonResponse(OrgRobotList, params=dict(orgname=ORGANIZATION))['robots']
|
||||
for r in self.getJsonResponse(OrgRobotList, params=params)['robots']
|
||||
]
|
||||
|
||||
def test_create_robot_with_underscores(self):
|
||||
|
@ -3256,6 +3257,9 @@ class TestOrgRobots(ApiTestCase):
|
|||
self.getJsonResponse(OrgRobot, params=dict(orgname=ORGANIZATION, robot_shortname='mr_bender'),
|
||||
expected_code=200)
|
||||
|
||||
# Make sure the robot shows up in the org robots list.
|
||||
self.assertTrue(membername in self.getRobotNames(include_permissions=True))
|
||||
|
||||
def test_delete_robot_after_use(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
|
|
Reference in a new issue