Ejemplo n.º 1
0
    def test_object_type(self):
        '''
    functions.class_type:  Tests that class data is a dictionary object.

    '''
        for c in self.classes:
            result = fetchClassData(c['class'], c['data'])
            self.assertIs(type(result), type({}))
    def test_object_type(self):
        """
    functions.class_type:  Tests that class data is a dictionary object.

    """
        for c in self.classes:
            result = fetchClassData(c["class"], c["data"])
            self.assertIs(type(result), type({}))
Ejemplo n.º 3
0
    def test_object_keys(self):
        '''
    functions.class_data:  Test for class data keys.

    '''
        for c in self.classes:
            keys = _fields(config, c['class'])
            result = fetchClassData(c['class'], c['data'])
            for key in keys:
                self.assertIn(key, result.keys())
    def test_object_keys(self):
        """
    functions.class_data:  Test for class data keys.

    """
        for c in self.classes:
            keys = _fields(config, c["class"])
            result = fetchClassData(c["class"], c["data"])
            for key in keys:
                self.assertIn(key, result.keys())
def fetchAndStore(key=None, id=None):
    '''
  Collects data from a class and handles its output either
  by storing it in a database or by constructing an error
  message to be delivered to the user.

  '''
    if key == 'resources':
        data = fetchResourceData(dataset_id=id)
        for resource in data:
            storeData(resource, key)

    else:
        data = fetchClassData(key, id)
        if data:
            storeData(data, key)
def fetchAndStore(key=None, id=None):
  '''
  Collects data from a class and handles its output either
  by storing it in a database or by constructing an error
  message to be delivered to the user.

  '''
  if key == 'resources':
    data = fetchResourceData(dataset_id=id)
    for resource in data:
      storeData(resource, key)

  else:
    data = fetchClassData(key, id)
    if data:
      storeData(data, key)