Beispiel #1
0
    def testForListOfOrgs(self):
        """Tests that proper connections are returned."""
        query = connection_logic.queryForOrganizations([self.first_org.key])
        # exhaust the query to check what entities are fetched
        connections = query.fetch(1000)
        self.assertSetEqual(
            set(connection.key for connection in connections),
            set([self.first_connection.key, self.second_connection.key]))

        query = connection_logic.queryForOrganizations([self.second_org.key])
        # exhaust the query to check what entities are fetched
        connections = query.fetch(1000)
        self.assertSetEqual(set(connection.key for connection in connections),
                            set([self.third_connection.key]))

        query = connection_logic.queryForOrganizations([self.third_org.key])
        # exhaust the query to check what entities are fetched
        connections = query.fetch(1000)
        self.assertSetEqual(set(connection.key for connection in connections),
                            set())

        query = connection_logic.queryForOrganizations(
            [self.first_org.key, self.second_org.key, self.third_org.key])
        # exhaust the query to check what entities are fetched
        connections = query.fetch(1000)
        self.assertSetEqual(
            set(connection.key for connection in connections),
            set([
                self.first_connection.key, self.second_connection.key,
                self.third_connection.key
            ]))
Beispiel #2
0
  def testForListOfOrgs(self):
    """Tests that proper connections are returned."""
    query = connection_logic.queryForOrganizations([self.first_org.key])
    # exhaust the query to check what entities are fetched
    connections = query.fetch(1000)
    self.assertSetEqual(
        set(connection.key for connection in connections),
        set([self.first_connection.key, self.second_connection.key]))

    query = connection_logic.queryForOrganizations([self.second_org.key])
    # exhaust the query to check what entities are fetched
    connections = query.fetch(1000)
    self.assertSetEqual(
        set(connection.key for connection in connections),
        set([self.third_connection.key]))

    query = connection_logic.queryForOrganizations([self.third_org.key])
    # exhaust the query to check what entities are fetched
    connections = query.fetch(1000)
    self.assertSetEqual(
        set(connection.key for connection in connections), set())

    query = connection_logic.queryForOrganizations(
        [self.first_org.key, self.second_org.key, self.third_org.key])
    # exhaust the query to check what entities are fetched
    connections = query.fetch(1000)
    self.assertSetEqual(
        set(connection.key for connection in connections),
        set([self.first_connection.key, self.second_connection.key,
            self.third_connection.key]))
Beispiel #3
0
 def _getQuery(self):
   """See ConnectionList._getQuery for specification."""
   if len(self.data.url_ndb_profile.admin_for) > 1:
     # explicit order by __key__ is required for MultiQuery,
     # i.e. a query with IN filter.
     return connection_logic.queryForOrganizations(
         self.data.url_ndb_profile.admin_for).order(
             connection_model.Connection._key)
   else:
     return connection_logic.queryForOrganizations(
         self.data.url_ndb_profile.admin_for)
Beispiel #4
0
 def testForEmptyList(self):
     """Tests that an error is raised for an empty list of organizations."""
     with self.assertRaises(ValueError):
         connection_logic.queryForOrganizations([])
Beispiel #5
0
 def testForEmptyList(self):
   """Tests that an error is raised for an empty list of organizations."""
   with self.assertRaises(ValueError):
     connection_logic.queryForOrganizations([])