Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 23, 2019
2 parents ecd8f26 + 8caccad commit de92d48
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions tests/test_analytics.py
Expand Up @@ -4,15 +4,16 @@
from algoliasearch.helpers import AlgoliaException


def test_ab_test_features(analytics, double_indexes, index):

def test_ab_test_features(analytics, double_indexes):
ab_test = {
'name': "Python client integration test",
'name': "Python client ab integration test",
'variants': [
{'index': double_indexes[0].index_name, 'trafficPercentage': 90},
{'index': double_indexes[1].index_name, 'trafficPercentage': 10},
{'index': index.index_name, 'trafficPercentage': 10},
],
'endAt': datetime.utcnow().replace(day=29).strftime("%Y-%m-%dT%H:%M:%SZ"),
'endAt': datetime.utcnow().replace(day=29).strftime(
"%Y-%m-%dT%H:%M:%SZ"),
}
response = analytics.add_ab_test(ab_test)
analytics.wait_task(response['index'], response['taskID'])
Expand All @@ -32,8 +33,41 @@ def test_ab_test_features(analytics, double_indexes):

response = analytics.delete_ab_test(ab_test_id)
analytics.wait_task(response['index'], response['taskID'])

try:
response = analytics.get_ab_test(ab_test_id)
analytics.get_ab_test(ab_test_id)
assert False
except AlgoliaException as e:
assert True


def test_aa_test_features(analytics, index):
response = index.save_object({
'objectID': 1,
})
analytics.wait_task(index.index_name, response['taskID'])

ab_test = {
'name': "Python client aa integration test",
'variants': [
{'index': index.index_name, 'trafficPercentage': 90},
{
'index': index.index_name, 'trafficPercentage': 10,
'customSearchParameters': {
'ignorePlurals': True
}
}
],
'endAt': datetime.utcnow().replace(day=29).strftime(
"%Y-%m-%dT%H:%M:%SZ"),
}
response = analytics.add_ab_test(ab_test)
analytics.wait_task(response['index'], response['taskID'])
ab_test_id = response['abTestID']

response = analytics.get_ab_test(ab_test_id)
assert response['name'] == ab_test['name']
assert response['status'] == 'active'

response = analytics.delete_ab_test(ab_test_id)
analytics.wait_task(response['index'], response['taskID'])

0 comments on commit de92d48

Please sign in to comment.