Exemplo n.º 1
0
  def testListProjects(self):
    '''
    Should make a well formatted call and return a list of Project instances
    '''

    # Create our client
    grok = Client(key = self.mockKey, connection = self.mockConnection)

    # Update our mock's repsonse for the next request
    response = {'projects': [{'name': 'project1', 'id': 1}, {'name': 'project2', 'id': 2}]}
    self.mockConnection.request.return_value = response

    # Make the call
    projects = grok.listProjects()

    self.mockConnection.request.assert_called_with('GET', self.projectsUrl,
                                                   params = {'all': True})

    self.assertIsInstance(projects, type([]))

    for project in projects:
      self.assertIsInstance(project, Project)