Exemple #1
0
 def test_query_param_not_number(self):
     with pytest.raises(Exception) as e:
         value = {'satisfaction_index': 'broken'}
         DatasetService().filter_service(value)
         assert str(
             e.value) == 'satisfaction_index parameter must be a number'
         assert e is not None
Exemple #2
0
 def test_query_param_ok(self):
     with app.app_context():
         number = random.uniform(0, 176075)
         value = {'satisfaction_index': number}
         result = DatasetService().filter_service(value)
         assert result is not None
         assert result.status_code == 200
Exemple #3
0
    def test_retrieve_list_of_countries(self):
        value = random.uniform(0, 176075)
        result = DatasetService().pd_service(value)

        assert result is not None
        assert len(result) > 0
        assert result[0]['Value'] > value
        assert result[-1]['Value'] > value
Exemple #4
0
 def test_query_param_smaller_than_zero(self):
     with pytest.raises(Exception) as e:
         value = {'satisfaction_index': -1}
         DatasetService().filter_service(value)
         assert str(
             e.value
         ) == 'satisfaction_index parameter must be equal or greater than 0'
         assert e is not None
Exemple #5
0
from services.dataset_service import DatasetService
from services.deskew_service import DeskewService

# We can load the dataset and compare how accurately we can determine the skew angle

# Open the dataset
dataset = DatasetService().openDataset()

# Track errors
errors = []

# Go through each item
for i in range(0, len(dataset)):
    # Get image and angle
    item = dataset[i]
    imageCv = item[0]
    correctAngle = item[1]

    # Calculate the angle, and compare it to real one
    guessedAngle = round(DeskewService().getSkewAngle(imageCv), 2)
    difference = abs(correctAngle - guessedAngle)
    differencePercentage = round(abs(difference / correctAngle) * 100, 2)

    # Debug, make sure that difference is less than 2% and track errors
    print('Item #' + str(i) + ', with angle=' + str(correctAngle) +
          ', calculated=' + str(guessedAngle) + ', difference=' +
          str(differencePercentage) + '%')
    assert differencePercentage < 2
    errors.append(differencePercentage)

print('Min Error: ' + str(min(errors)) + '%')
Exemple #6
0
from services.dataset_service import DatasetService

# We can create a new dataset
DatasetService().generateDataset()
Exemple #7
0
    def test_retrieve_empty_list(self):
        value = 1000000
        result = DatasetService().pd_service(value)

        assert result is not None
        assert len(result) == 0
Exemple #8
0
 def test_query_param_not_supplied(self):
     with pytest.raises(Exception) as e:
         value = {'wrong_parameter': -1}
         DatasetService().filter_service(value)
         assert str(e.value) == 'satisfaction_index parameter is required'
         assert e is not None