-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from weni-ai/feature/return-full-number-in-rec…
…urrence-chart Feature/return full number in recurrence chart
- Loading branch information
Showing
2 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from random import randint | ||
from django.test import TestCase | ||
from django.utils.crypto import get_random_string | ||
|
||
from insights.sources.flowruns.usecases.query_execute import transform_results_data | ||
|
||
|
||
class TestFlowRunDataTransformation(TestCase): | ||
def setUp(self): | ||
counts = [randint(1, 10) for i in range(2)] | ||
|
||
self.total = sum(counts) | ||
self.terms_agg_buckets = [] | ||
|
||
for count in counts: | ||
self.terms_agg_buckets.append( | ||
{"key": get_random_string(10), "doc_count": count} | ||
) | ||
|
||
def test_flowrun_data_transformation(self): | ||
results = transform_results_data(self.total, 0, self.terms_agg_buckets) | ||
|
||
for result in results: | ||
self.assertEqual( | ||
result["value"], | ||
round(((result["full_value"] / self.total) * 100), 2), | ||
) |