def a_refresh_token():
    return jwt.encode(
        {
            'exp': 0,
            'azp': a_string(),
            'iss': 'http://{}.com'.format(a_string())
        }, SECRET)
Ejemplo n.º 2
0
    def test_get_experiments_with_scalar_params(self):
        # given
        leaderboard_entries = [MagicMock() for _ in range(0, 2)]
        self.client.get_leaderboard_entries.return_value = leaderboard_entries

        # and
        params = dict(id=a_string(),
                      group=a_string(),
                      state='succeeded',
                      owner=a_string(),
                      tag=a_string(),
                      min_running_time=randint(1, 100))

        # when
        experiments = self.project.get_experiments(**params)

        # then
        expected_params = dict(namespace=self.project.namespace,
                               project_name=self.project.name,
                               ids=[params['id']],
                               group_ids=[params['group']],
                               states=[params['state']],
                               owners=[params['owner']],
                               tags=[params['tag']],
                               min_running_time=params['min_running_time'])
        self.client.get_leaderboard_entries.assert_called_once_with(
            **expected_params)

        # and
        expected_experiments = [
            Experiment(self.client, entry) for entry in leaderboard_entries
        ]
        self.assertEqual(expected_experiments, experiments)
Ejemplo n.º 3
0
 def setUp(self):
     super(TestProject, self).setUp()
     self.client = MagicMock()
     self.project = Project(client=self.client,
                            internal_id=a_uuid_string(),
                            namespace=a_string(),
                            name=a_string())
def an_access_token():
    return jwt.encode(
        {
            'exp': time.time(),
            'azp': a_string(),
            'iss': 'http://{}.com'.format(a_string())
        }, SECRET)
Ejemplo n.º 5
0
def a_request():
    request = MagicMock()
    request.method = 'post'
    request.url = 'http://{}.com'.format(a_string())
    request.headers = {a_string(): a_string()}
    request.body = a_string()
    return request
Ejemplo n.º 6
0
def a_parameter():
    p = MagicMock()
    p.id = a_uuid_string()
    p.name = a_string()
    p.parameterType = 'double'
    p.value = str(uniform(-100, 100))
    return p
Ejemplo n.º 7
0
def a_registered_project_member(username=None):
    if username is None:
        username = a_string()

    registered_member_info = MagicMock()
    registered_member_info.avatarSource = 'default'
    registered_member_info.avatarUrl = ''
    registered_member_info.firstName = a_string()
    registered_member_info.lastName = a_string()
    registered_member_info.username = username

    project_member = MagicMock()
    project_member.invitationInfo = None
    project_member.registeredMemberInfo = registered_member_info
    project_member.role = 'manager'

    return project_member
Ejemplo n.º 8
0
def a_channel_value():
    cv = MagicMock()
    cv.channelId = a_uuid_string()
    cv.channelName = a_string()
    cv.channelType = 'numeric'
    cv.x = uniform(1, 100)
    cv.y = str(uniform(1, 100))
    return cv
Ejemplo n.º 9
0
def an_invited_project_member():
    invitation_info = MagicMock()
    invitation_info.id = a_uuid_string()
    invitation_info.email = a_string() + '@example.com'

    project_member = MagicMock()
    project_member.invitationInfo = invitation_info
    project_member.registeredMemberInfo = None
    project_member.role = 'member'

    return project_member
Ejemplo n.º 10
0
    def test_get_members(self):
        # given
        member_usernames = [a_string() for _ in range(0, 2)]
        members = [
            a_registered_project_member(username)
            for username in member_usernames
        ]

        # and
        self.client.get_project_members.return_value = members + [
            an_invited_project_member()
        ]

        # when
        fetched_member_usernames = self.project.get_members()

        # then
        self.client.get_project_members.assert_called_once_with(
            self.project.internal_id)

        # and
        self.assertEqual(member_usernames, fetched_member_usernames)
Ejemplo n.º 11
0
def a_property():
    p = MagicMock()
    p.key = a_string()
    p.value = a_string()
    return p
Ejemplo n.º 12
0
def a_project():
    project = MagicMock()
    project.id = a_uuid_string()
    project.name = a_string()
    return project
Ejemplo n.º 13
0
def a_group_leaderboard_entry_dto():
    entry = MagicMock()
    entry.entryType = 'group'
    entry.id = a_uuid_string()
    entry.shortId = a_string()
    entry.projectId = a_uuid_string()
    entry.state = 'succeeded'
    entry.experimentStates = an_experiment_states()
    entry.responding = True
    entry.name = a_string()
    entry.organizationName = a_string()
    entry.projectName = a_string()
    entry.description = a_string()
    entry.timeOfCreation = a_timestamp()
    entry.timeOfCompletion = a_timestamp()
    entry.runningTime = randint(1, 1000)
    entry.owner = a_string()
    entry.size = randint(1, 1000)
    entry.tags = [a_string(), a_string()]
    entry.environment = a_string()
    entry.workerType = a_string()
    entry.hostname = a_string()
    entry.sourceSize = randint(1, 1000)
    entry.sourceMd5 = a_string()
    entry.commitId = a_string()
    entry.properties = [a_property(), a_property()]
    entry.parameters = [a_parameter(), a_parameter()]
    entry.channelsLastValues = [a_channel_value(), a_channel_value()]
    entry.trashed = False
    entry.deleted = False
    entry.isBestExperiment = False
    return entry