예제 #1
0
class TestIngesterFunctionality(unittest.TestCase):
    """This set of tests test the actual functioning of the service.
    """
    def setUp(self):
        self.auth = CredentialsAuthentication("casey", "password")
        self.ingester_platform = IngesterPlatformAPI("http://localhost:8080/api", self.auth)
        self.cleanup_files = []
        
    def test_pull_ingest_functionality(self):
        loc = Location(10.0, 11.0, "Test Site", 100, None)
        loc = self.ingester_platform.post(loc)
        
        file_schema = DataEntrySchema()
        file_schema.addAttr(FileDataType("file"))
        file_schema = self.ingester_platform.post(file_schema)
        
        dataset = Dataset(location=loc.id, schema=file_schema.id, data_source=PullDataSource("http://www.bom.gov.au/radar/IDR733.gif", "file", sampling=PeriodicSampling(10000)))
        dataset1 = self.ingester_platform.post(dataset)
        self.assertEquals(dataset1.location, dataset.location, "Location ID does not match")
        self.assertEquals(dataset1.schema, dataset.schema, "schema does not match")
        
        self.ingester_platform.disableDataset(dataset1.id)

        dataset1a = self.ingester_platform.getDataset(dataset1.id)
        self.assertEquals(dataset1a.enabled, False)



    def tearDown(self):
        self.ingester_platform.reset()
예제 #2
0
class CLIClient(object):
    def __init__(self, server):
        self.client = IngesterPlatformAPI(server, None)

    def file_or_json(self, s):
        """Try to open the file or parse the string as JSON"""
        obj = None
        if os.path.exists(s):
            with open(r, "r") as f:
                obj = json.load(f)
        else:
            obj = json.loads(s)
        return self.client._marshaller.dict_to_obj(obj)

    def ping(self):
        return self.client.ping()

    def enable(self, ds_id):
        return self.client.enableDataset(ds_id)

    def disable(self, ds_id):
        return self.client.disableDataset(ds_id)

    def search(self, criteria, limit=20, offset=0):
        return self.client._marshaller.obj_to_dict(
            self.client.search(self.file_or_json(criteria), int(offset),
                               int(limit)))

    def logs(self, ds_id):
        return self.client._marshaller.obj_to_dict(
            self.client.getIngesterLogs(ds_id))

    def post(self, s):
        obj = self.file_or_json(s)
        return (self.client._marshaller.obj_to_dict(self.client.post(obj)))

    def get(self, *args):
        if args[0] == "schema":
            return (self.client.getSchema(args[1]))
        elif args[0] == "location":
            return (self.client.getLocation(args[1]))
        elif args[0] == "dataset":
            return (self.client.getDataset(args[1]))
예제 #3
0
class CLIClient(object):

    def __init__(self, server):
        self.client = IngesterPlatformAPI(server, None)
    
    def file_or_json(self, s):
        """Try to open the file or parse the string as JSON"""
        obj = None
        if os.path.exists(s):
            with open(r, "r") as f:
                obj = json.load(f)
        else:
            obj = json.loads(s)
        return self.client._marshaller.dict_to_obj(obj)

    def ping(self):
        return self.client.ping()

    def enable(self, ds_id):
        return self.client.enableDataset(ds_id)

    def disable(self, ds_id):
        return self.client.disableDataset(ds_id)

    def search(self, criteria, limit=20, offset=0):
        return self.client._marshaller.obj_to_dict(self.client.search(self.file_or_json(criteria), int(offset), int(limit)))

    def logs(self, ds_id):
        return self.client._marshaller.obj_to_dict(self.client.getIngesterLogs(ds_id))

    def post(self, s):
        obj = self.file_or_json(s)
        return (self.client._marshaller.obj_to_dict(self.client.post(obj)))

    def get(self, *args):
        if args[0] == "schema":
            return (self.client.getSchema(args[1])) 
        elif args[0] == "location":
            return (self.client.getLocation(args[1])) 
        elif args[0] == "dataset":
            return (self.client.getDataset(args[1])) 
예제 #4
0
class TestIngesterFunctionality(unittest.TestCase):
    """This set of tests test the actual functioning of the service.
    """
    def setUp(self):
        self.auth = CredentialsAuthentication("casey", "password")
        self.ingester_platform = IngesterPlatformAPI(
            "http://localhost:8080/api", self.auth)
        self.cleanup_files = []

    def test_pull_ingest_functionality(self):
        loc = Location(10.0, 11.0, "Test Site", 100, None)
        loc = self.ingester_platform.post(loc)

        file_schema = DataEntrySchema()
        file_schema.addAttr(FileDataType("file"))
        file_schema = self.ingester_platform.post(file_schema)

        dataset = Dataset(location=loc.id,
                          schema=file_schema.id,
                          data_source=PullDataSource(
                              "http://www.bom.gov.au/radar/IDR733.gif",
                              "file",
                              sampling=PeriodicSampling(10000)))
        dataset1 = self.ingester_platform.post(dataset)
        self.assertEquals(dataset1.location, dataset.location,
                          "Location ID does not match")
        self.assertEquals(dataset1.schema, dataset.schema,
                          "schema does not match")

        self.ingester_platform.disableDataset(dataset1.id)

        dataset1a = self.ingester_platform.getDataset(dataset1.id)
        self.assertEquals(dataset1a.enabled, False)

    def tearDown(self):
        self.ingester_platform.reset()