def test_making_order_with_no_orders(self):
     data1 = {
         "data1": {
             "customer": {
                 "ssn": my_ssn,
                 "firstname": "Sven",
                 "lastname": "Svensson",
                 "address": "Bolagsvägen 24",
                 "zipcode": "11325",
                 "locality": "Stockholm",
                 "country_code": "SE",
                 "email": "*****@*****.**",
                 "telephone": "0701234567",
                 "ip_address": "2001:0db8:0000:0042:0000:8a2e:0370:7334"
             },
             "orders": [],
             "dry": True
         }
     }
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header, **data1)
     #print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": False,
             "content": {
                 "identifier":
                 "invalid_request",
                 "reason":
                 "Malformed orders: Order #1: Object is not in the correct format. Order #0: Object is not in the correct format"
             }
         })
 def test_making_order_with_a_empty_customer_and_no_orders(self):
     data1 = {"data1": {"customer": {}, "orders": [], "dry": True}}
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header, **data1)
     # print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": False,
             "content": {
                 "identifier":
                 "invalid_request",
                 "reason":
                 "Malformed customer: ssn field is missing. "
                 "firstname field is missing. "
                 "lastname field is missing. "
                 "address field is missing. "
                 "zipcode field is missing. "
                 "locality field is missing. "
                 "country_code field is missing. "
                 "email field is missing. "
                 "telephone field is missing. "
                 "ip_address field is missing"
             }
         })
Ejemplo n.º 3
0
 def test_making_FI_order_with_no_orders(self):
     data1 = {"data1": {
         "customer": {"ssn": "111111-1111", "firstname": "Finsk", "lastname": "Finnson", "address": "Fin 24",
                      "zipcode": "11325", "locality": "Helsinki", "country_code": "FI",
                      "email": "*****@*****.**", "telephone": "0701234567", "ip_address": ""}, "orders": [], "dry": True}}
     result = get_result_from_requests(**FIWebshopTest.apiUrl, **FIWebshopTest.apiEndpoint, **FIWebshopTest.header, **data1)
     #print("\n" + str(result) + "\n")
     self.assertEqual(result, {"success": False, "content": {"identifier": "invalid_request", "reason": "Malformed orders: Order #1: Object is not in the correct format. Order #0: Object is not in the correct format"}})
Ejemplo n.º 4
0
 def test_making_FI_order_with_a_short_ssn_field(self):
     data1 = {"data1": {
         "customer": {"ssn": "11-111", "firstname": "Finsk", "lastname": "Finnson", "address": "Fin 24",
                      "zipcode": "11325", "locality": "Helsinki", "country_code": "FI",
                      "email": "*****@*****.**", "telephone": "0701234567", "ip_address": ""}, "orders": [
             {"article": "10000051", "quantity": 1, "reference1": "CompanyABC", "reference2": "Something",
              "reference3": "", "invite_ssn": ""}], "dry": True}}
     result = get_result_from_requests(**FIWebshopTest.apiUrl, **FIWebshopTest.apiEndpoint, **FIWebshopTest.header, **data1)
    # print("\n" + str(result) + "\n")
     self.assertEqual(result, {"success": False, "content": {"identifier": "invalid_customer", "reason": "Invalid customer data: ssn field is invalid"}})
 def test_get_without_any_inputs(self):
     #apiUrl = {"apiUrl": "http://127.0.0.1:8000/api/v1/"}
     apiUrl = {"apiUrl": "https://tools.incodaq.com/api/v1/"}
     apiEndpoint = {"apiEndpoint": "formattelnumbers/"}
     result = get_result_from_requests(**apiUrl, **apiEndpoint)
     #print(str(result))
     self.assertEqual(
         result, {
             'status': 'FAILED ',
             'message': 'No country code and no telephone numbers'
         })
 def test_get_without_tel_numbers(self):
     # apiUrl = {"apiUrl": "http://127.0.0.1:8000/api/v1/"}
     apiUrl = {"apiUrl": "https://tools.incodaq.com/api/v1/"}
     apiEndpoint = {"apiEndpoint": "formattelnumbers/"}
     payload = {"params1": {"country_code": "SE"}}
     result = get_result_from_requests(**apiUrl, **apiEndpoint, **payload)
     #print(str(result))
     self.assertEqual(result, {
         'status': 'FAILED ',
         'message': 'No telephone numbers'
     })
 def test_get_without_any_inputs(self):
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint)
     #print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": False,
             "content": {
                 "identifier": "api_key",
                 "reason": "The API key is missing"
             }
         })
Ejemplo n.º 8
0
 def test_making_FI_order_with_made_up_FI_test_customer(self):
     data1 = {"data1": {
         "customer": {"ssn": "111111-1111", "firstname": "Finsk", "lastname": "Finnson", "address": "Fin 24",
                      "zipcode": "11325", "locality": "Helsinki", "country_code": "FI",
                      "email": "*****@*****.**", "telephone": "0701234567", "ip_address": ""}, "orders": [
             {"article": "10000051", "quantity": 1, "reference1": "CompanyABC", "reference2": "Something",
              "reference3": "", "invite_ssn": ""}], "dry": True}}
     result = get_result_from_requests(**FIWebshopTest.apiUrl, **FIWebshopTest.apiEndpoint, **FIWebshopTest.header,
                                       **data1)
     # print("\n" + str(result) + "\n")
     self.assertEqual(result, {"success": True, "content": {'orders': [{'amount': 10,
                                                                        'article': '10000051', 'currency': 'EUR',
                                                                        'id': 'dry', 'reference': 'CompanyABC'}]}})
 def test_get_only_header(self):
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header)
     #print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": False,
             "content": {
                 "identifier": "invalid_request",
                 "reason": "The request JSON is non existent"
             }
         })
 def test_making_SE_order_with_two_long_product_ids(self):
     data1 = {
         "data1": {
             "customer": {
                 "ssn": my_ssn,
                 "firstname": "Sven",
                 "lastname": "Svensson",
                 "address": "Bolagsvägen 24",
                 "zipcode": "11325",
                 "locality": "Stockholm",
                 "country_code": "SE",
                 "email": "*****@*****.**",
                 "telephone": "0701234567",
                 "ip_address": "2001:0db8:0000:0042:0000:8a2e:0370:7334"
             },
             "orders": [{
                 "article": "1000131230051",
                 "quantity": 1,
                 "reference1": "CompanyABC",
                 "reference2": "Something",
                 "reference3": "",
                 "invite_ssn": ""
             }, {
                 "article": "100000000000051",
                 "quantity": 1,
                 "reference1": "CompanyABC",
                 "reference2": "Something",
                 "reference3": "",
                 "invite_ssn": ""
             }],
             "dry":
             True
         }
     }
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header, **data1)
     # print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": False,
             "content": {
                 'identifier':
                 'invalid_order',
                 'reason':
                 'Invalid orders: Order #1: article field is too long. '
                 'Order #2: article field is too long'
             }
         })
 def test_get_without_country_code(self):
     # apiUrl = {"apiUrl": "http://127.0.0.1:8000/api/v1/"}
     apiUrl = {"apiUrl": "https://tools.incodaq.com/api/v1/"}
     apiEndpoint = {"apiEndpoint": "formattelnumbers/"}
     payload = {
         "params1": {
             "telephone_numbers":
             "+46731264413,0046731212345,+4673123-4412,004673 123-3332,076 111 12 34,75 113 1244,08 444 555,085556666,08-123-1234,08555-6666"
         }
     }
     result = get_result_from_requests(**apiUrl, **apiEndpoint, **payload)
     # print(str(result))
     self.assertEqual(result, {
         'status': 'FAILED ',
         'message': 'No country code'
     })
 def test_making_order_with_a_ok_ssn_field(self):
     data1 = {
         "data1": {
             "customer": {
                 "ssn": my_ssn,
                 "firstname": "Sven",
                 "lastname": "Svensson",
                 "address": "Bolagsvägen 24",
                 "zipcode": "11325",
                 "locality": "Stockholm",
                 "country_code": "SE",
                 "email": "*****@*****.**",
                 "telephone": "0701234567",
                 "ip_address": "2001:0db8:0000:0042:0000:8a2e:0370:7334"
             },
             "orders": [{
                 "article": "10000051",
                 "quantity": 1,
                 "reference1": "CompanyABC",
                 "reference2": "Something",
                 "reference3": "",
                 "invite_ssn": ""
             }],
             "dry":
             True
         }
     }
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header, **data1)
     #print("\n" + str(result) + "\n")
     self.assertEqual(
         result, {
             "success": True,
             "content": {
                 'orders': [{
                     "id": "dry",
                     "reference": "CompanyABC",
                     "article": "10000051",
                     "amount": 98,
                     "currency": "SEK"
                 }]
             }
         })
 def test_get_FI_full_input(self):
     # apiUrl = {"apiUrl": "http://127.0.0.1:8000/api/v1/"}
     apiUrl = {"apiUrl": "https://tools.incodaq.com/api/v1/"}
     apiEndpoint = {"apiEndpoint": "formattelnumbers/"}
     testlist = "+58731264413,0058731212345,+358 7 3123-4412,+5873123-4412,005873 123-3332,076 111 12 34,75 113 1244,08 444 555,085556666,08-123-1234,08555-6666"
     payload = {
         "params1": {
             "country_code": "FI",
             "telephone_numbers": testlist
         }
     }
     result = get_result_from_requests(**apiUrl, **apiEndpoint, **payload)
     #print(str(result))
     self.assertEqual(
         result, {
             'status':
             'SUCCESS',
             'country_code':
             'FI',
             'telephone_numbers':
             '0731264413,0731212345,0731234412,0731234412,0731233332,0761111234,0751131244,08444555,085556666,081231234,085556666'
         })
 def test_order_with_zero_quantity(self):
     data1 = {
         "data1": {
             "customer": {
                 "ssn": my_ssn,
                 "firstname": "Sven",
                 "lastname": "Svensson",
                 "address": "Bolagsvägen 24",
                 "zipcode": "11325",
                 "locality": "Stockholm",
                 "country_code": "SE",
                 "email": "*****@*****.**",
                 "telephone": "0701234567",
                 "ip_address": "2001:0db8:0000:0042:0000:8a2e:0370:7334"
             },
             "orders": [{
                 "article": "10000051",
                 "quantity": 0,
                 "reference1": "CompanyABC",
                 "reference2": "Something",
                 "reference3": "",
                 "invite_ssn": ""
             }],
             "dry":
             True
         }
     }
     result = get_result_from_requests(**SEWebshopTest.apiUrl,
                                       **SEWebshopTest.apiEndpoint,
                                       **SEWebshopTest.header, **data1)
     #print("\n  " + str(result) + "\n")
     self.assertEqual(result, {
         "success": True,
         "content": {
             "orders": []
         }
     })  # This should not be the response
Ejemplo n.º 15
0
 def test_making_FI_order_with_only_test_customer_provided_in_documentation(self):
     data1 = {"data1":{"customer":{"ssn":"1234567890","firstname":"Sven","lastname":"Svensson","address":"Bolagsvägen 24","zipcode":"11325","locality":"Stockholm","country_code":"FI","email":"*****@*****.**","telephone":"0701234567","ip_address":"2001:0db8:0000:0042:0000:8a2e:0370:7334"},"orders":[{"article":"10000051","quantity":1,"reference1":"CompanyABC","reference2":"Something","reference3":"","invite_ssn":""}],"dry":True}}
     result = get_result_from_requests(**FIWebshopTest.apiUrl, **FIWebshopTest.apiEndpoint, **FIWebshopTest.header, **data1)
    # print("\n" + str(result) + "\n")
     self.assertEqual(result, {"success": False, "content": {"identifier": "invalid_customer", "reason": "Invalid customer data: ssn field is invalid"}})