def test_check_one_seller_email_found(): brief_data = { 'sellerSelector': 'oneSeller', 'sellerEmail': '*****@*****.**' } errs = {} with patch.object(users, 'get_sellers_by_email', return_value=[User()]) as get_sellers_by_email: error = check_seller_emails(brief_data, errs) assert error is None
def test_check_some_seller_email_answered(): test_cases = [{ 'sellerSelector': 'someSellers', 'sellerEmailList': [ '*****@*****.**' ] }] errs = {} with patch.object(users, 'get_sellers_by_email', return_value=[User()]) as get_sellers_by_email: for test_case in test_cases: error = check_seller_emails(test_case, errs) assert error is None
def test_check_some_seller_email_unanswered(): test_cases = [{ 'sellerSelector': 'someSellers', 'sellerEmailList': [] }, { 'sellerSelector': 'someSellers' }] errs = {} with patch.object(users, 'get_sellers_by_email', return_value=[]) as get_sellers_by_email: for test_case in test_cases: error = check_seller_emails(test_case, errs) assert error is not None assert error['sellerEmailList'] == 'answer_required'
def test_check_seller_email_return_none_when_error(): brief_data = { 'sellerSelector': 'someSellers', 'sellerEmailList': [ '*****@*****.**' ] } errs = { 'sellerEmailList': 'invalid_format' } with patch.object(users, 'get_sellers_by_email', return_value=[]) as get_sellers_by_email: error = check_seller_emails(brief_data, errs) assert error is None
def test_check_one_seller_email_not_found(): brief_data = { 'sellerSelector': 'oneSeller', 'sellerEmail': '*****@*****.**' } errs = {} with \ patch.object(users, 'get_sellers_by_email', return_value=[]) as get_sellers_by_email, \ patch.object(suppliers, 'get_suppliers_by_contact_email', return_value=[]) as get_suppliers_by_contact_email: error = check_seller_emails(brief_data, errs) assert error is not None assert error['sellerEmail'] == '[email protected]'
def test_contact_email_found_for_some_sellers(): brief_data = { 'sellerEmailList': ['*****@*****.**'], 'sellerSelector': 'someSellers' } errs = {} with \ patch.object(users, 'get_sellers_by_email', return_value=[]) as get_sellers_by_email, \ patch.object(suppliers, 'get_suppliers_by_contact_email', return_value=[Supplier(data={ 'contact_email': '*****@*****.**' })]) as get_suppliers_by_contact_email: error = check_seller_emails(brief_data, errs) assert error is None