# from secrets import choice
# from django.urls import reverse
# from django.shortcuts import render, redirect
# import pytest
# from apps.accounts.models import User
# import json
# from faker import Faker
# # from .conftest import faker_users_gen
# from termcolor import colored
# from django.conf import settings
# from apps.subscriptions.models import *
# faker = Faker()
# # from hypothesis import given, note, strategies as st
# import random
#
# # @pytest.mark.skip
# def test_100_signup_user_with_one_membership_type(db, client, mailoutbox,user_signup_data_already_signup):
#     Plan.objects.create(plan_id='P-2E356653NJ554300BML54IQY',plan_type='Basic',plan_name='Basic plan',describe='Basic access for 5 days',
#                         duration_days=30,price=10.3,paymentSource='paypal').save()
#     # EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
#     assert User.objects.all().count() == 0
#     for i in range(0,10):
#         session = client.session
#         session['plan'] = ['P-2E356653NJ554300BML54IQY'],
#         data = {'first_name': faker.name().split(' ')[0],
#                 'last_name': faker.name().split(' ')[1],
#                 'email': faker.unique.email(),
#                 'password': faker.bban(),
#                 'session': session['plan'],
#                 'membership':'P-2E356653NJ554300BML54IQY'
#                 }
#         data_1 = {
#                 'first_name': faker.name().split(' ')[0],
#                 'last_name': faker.name().split(' ')[1],
#                 'email': faker.unique.email(),
#                 'password': faker.bban(),
#                 'session': session['plan'],
#                 'OrderID':'8071106362699621P',
#
#                 'ConversationID':'A21AALrDjl8qdG3psAL0OXp18uWQ7qdlOcH0IpMKMEF6COtX0JcABunbkfEElf1s43scSCGgZ2HZzo-POo4n-6ofljlg5faCw'
#         }
#         response = client.post(path=reverse('accounts:signup'), data=data)
#         json_response = json.loads(response.content)
#         print(colored(response.status_code,'yellow'))
#         if json_response['result'] == 'Found Success':
#             res = client.post(reverse('accounts:signup'),data=data_1)
#             js_res = json.loads(res.content)
#             assert User.objects.all().count() == i+1
#             print(colored(json.loads(res.content),'yellow'))
#             assert js_res['result'] == 'success'
#             assert js_res['message'] == f"You are signed up. Check your email {data_1['email']} to activate your account."
#             # test email
#             mail = mailoutbox[0]
#             assert len(mailoutbox) == i+1
#             assert mail.subject == f"UseVoice. | Account Confirmation"
#             assert Profile.objects.all().count() == i+1
#             assert Payment.objects.all().count() == i+1
#
#         print(colored(json.loads(response.content),'blue'))
#
#
#
# def test_multi_subscribers_with_different_membershis(client,db,mailoutbox):
#     Plan.objects.create(plan_id='P-2E356653NJ554300BML54IQY',plan_type='Basic',plan_name='Basic plan',describe='Basic access for 5 days',
#                         duration_days=30,price=10.3,paymentSource='paypal').save()
#     Plan.objects.create(plan_id='demo',plan_type='Free',plan_name='Basic plan',describe='Free access for 5 days',
#                         duration_days=30,price=0,paymentSource='paypal').save()
#     Plan.objects.create(plan_id='P-2E356653NJ554300BML54IUY',plan_type='Pro',plan_name='Pro plan',describe='Pro access for 5 days',
#                         duration_days=30,price=10.3,paymentSource='paypal').save()
#
#     assert User.objects.all().count() == 0
#     planes = ['P-2E356653NJ554300BML54IQY','demo','P-2E356653NJ554300BML54IUY']
#     for i in range(0,10):
#         session = client.session
#         session['plan'] = random.choice(planes)
#         print(colored(session['plan'],'red'))
#         data = {'first_name': faker.name().split(' ')[0],
#                 'last_name': faker.name().split(' ')[1],
#                 'email': faker.unique.email(),
#                 'password': faker.bban(),
#                 'session': session['plan'],
#                 'membership':session['plan']
#                 }
#         data_1 = {
#                 'first_name': faker.name().split(' ')[0],
#                 'last_name': faker.name().split(' ')[1],
#                 'email': faker.unique.email(),
#                 'password': faker.bban(),
#                 'session': session['plan'],
#                 'OrderID':'8071106362699621P',
#
#                 'ConversationID':'A21AALrDjl8qdG3psAL0OXp18uWQ7qdlOcH0IpMKMEF6COtX0JcABunbkfEElf1s43scSCGgZ2HZzo-POo4n-6ofljlg5faCw'
#         }
#         response = client.post(path=reverse('accounts:signup'), data=data)
#         json_response = json.loads(response.content)
#
#         print(colored(response.status_code,'yellow'))
#         if json_response['result'] == 'Found Success':
#             res = client.post(reverse('accounts:signup'),data=data_1)
#             js_res = json.loads(res.content)
#             print(colored(json.loads(res.content),'yellow'))
#             assert js_res['result'] == 'success'
#             assert js_res['message'] == f"You are signed up. Check your email {data_1['email']} to activate your account."
#             assert Subscription.objects.all().count() == i+1
#             # test email
#
#             mail = mailoutbox[0]
#             assert mail.subject == f"UseVoice. | Account Confirmation"
#
#
