Robottelo: Rename "datacheck" decorator for something meaninful

Created on 17 Jun 2016  路  4Comments  路  Source: SatelliteQE/robottelo

This is the current datacheck decorator used widely in our test factories

def datacheck(func):
    """Overrides the data creator functions in this class to return 1 value
    If run_one_datapoint=false, return the entire data set. (default: False)
    If run_one_datapoint=true, return a random data.
    """
    @wraps(func)
    def func_wrapper(*args, **kwargs):
        """Perform smoke test attribute check"""
        dataset = func(*args, **kwargs)
        if settings.run_one_datapoint:
            dataset = [random.choice(dataset)]
        return dataset
    return func_wrapper

When I read the name datacheck I imagine some checks being done in data or maybe some validation but actually it is just filtering he data randomly if the run_one_datapoint config option is set to true.

I was thinking if this is not a good idea to change the name of this decorator to something more explicit.

def datapoint_filtered(func):
    """Overrides the data creator functions in this class to return 1 value
    If run_one_datapoint=false, return the entire data set. (default: False)
    If run_one_datapoint=true, return a random data.
    """

ideas?

Question

Most helpful comment

@omaciel @elyezer @abalakh I like filtered_datapoint

All 4 comments

I fell the same when reading that decorator name. I would suggest something like one_datapoint or maybe smart_datapoint then the docstring would compliment what smart means.

And yes, naming is hard :smile:

@rochacbruno how about filtered_data or filtered_datapoint?

@omaciel @elyezer @abalakh I like filtered_datapoint

I totally missed this issue. datafilter would have suited as well.

Was this page helpful?
0 / 5 - 0 ratings