Exemple #1
0
    def test_client_class_validate_server_url(self) -> None:
        apiKey = tests_utils.gen_string(12)
        clientId = tests_utils.gen_string(12)
        apiSecret = tests_utils.gen_string(12)

        with self.assertRaises(ValueError):
            serverDomain = tests_utils.gen_string(12)
            clientClass = SalesManagoClientService(apiKey=apiKey,
                                                   clientId=clientId,
                                                   apiSecret=apiSecret,
                                                   serverDomain=serverDomain)
    def setUp(self) -> None:
        apiKey = tests_utils.gen_string(12)
        clientId = tests_utils.gen_string(12)
        apiSecret = tests_utils.gen_string(12)
        serverDomain = 'app1.salesmanago.com'

        self.clientClass = SalesManagoEventService(
            apiKey=apiKey, clientId=clientId, 
            apiSecret=apiSecret, serverDomain=serverDomain
        )

        self.clientDataMock = self.clientClass.createEventData(self._min_event_data())
    def test_generate_request_payload_batchAddContactExtEvent_checks_same_owner(self) -> None:
        events = []

        for x in range(0,10):
            dt = self._min_event_data(fields=['contactId', 'eventDate', 'contactExtEventType'])
            dt['owner'] = '%s@%s.com' % (tests_utils.gen_string(16), tests_utils.gen_string(4))

            events.append(
                self.clientClass.createEventData(dt)
            )

        with self.assertRaises(ValueError):
            self.clientClass._generate_payload(events, 'batchAddContactExtEvent')
Exemple #4
0
    def test_client_class_basic_init(self) -> None:
        apiKey = tests_utils.gen_string(12)
        clientId = tests_utils.gen_string(12)
        apiSecret = tests_utils.gen_string(12)
        serverDomain = 'app1.salesmanago.com'

        clientClass = SalesManagoClientService(apiKey=apiKey,
                                               clientId=clientId,
                                               apiSecret=apiSecret,
                                               serverDomain=serverDomain)

        self.assertEqual(clientClass.apiKey, apiKey)
        self.assertEqual(clientClass.clientId, clientId)
        self.assertEqual(clientClass.apiSecret, apiSecret)
        self.assertEqual(clientClass.serverDomain, serverDomain)
    def setUp(self) -> None:
        apiKey = tests_utils.gen_string(12)
        clientId = tests_utils.gen_string(12)
        apiSecret = tests_utils.gen_string(12)
        serverDomain = 'app1.salesmanago.com'

        self.clientClass = SalesManagoClientService(apiKey=apiKey,
                                                    clientId=clientId,
                                                    apiSecret=apiSecret,
                                                    serverDomain=serverDomain)

        self.clientDataMock = self.clientClass.createClientData({
            'email':
            '*****@*****.**',
            'owner':
            '*****@*****.**'
        })
Exemple #6
0
    def _rich_client_data(self,
                          fields=None,
                          no_address=False,
                          no_contact=False):
        raw = {
            'name': tests_utils.gen_string(random.randint(4, 120)),
            'email': self.CLIENT_MAIL,
            'owner': self.OWNER_MAIL,
            'phone': tests_utils.gen_string(random.randint(4, 120)),
            'fax': tests_utils.gen_string(random.randint(4, 120)),
            'company': tests_utils.gen_string(random.randint(4, 120)),
            'birthday': datetime.date(1982, 1, 1),
            'newEmail': '*****@*****.**',
            'address_streetAddress':
            tests_utils.gen_string(random.randint(4, 120)),
            'address_zipCode': tests_utils.gen_string(random.randint(4, 120)),
            'address_city': tests_utils.gen_string(random.randint(4, 120)),
            'address_country': tests_utils.gen_string(random.randint(2, 4)),
            'externalId': tests_utils.gen_string(random.randint(4, 120)),
            'lang': 'PL',
            'state': random.choice(self.VALID_STATES),
            'forceOptOut': tests_utils.gen_true_false(),
            'forceOptIn': tests_utils.gen_true_false(),
            'forcePhoneOptOut': tests_utils.gen_true_false(),
            'forcePhoneOptIn': tests_utils.gen_true_false(),
            'useApiDoubleOptIn': tests_utils.gen_true_false(),
            'province': tests_utils.gen_string(random.randint(4, 120))
        }

        if fields:
            raw = {k: v for k, v in raw.items() if k in fields}

        if no_address:
            raw = {k: v for k, v in raw.items() if 'address_' not in k}

        if no_contact:
            raw = {
                k: v
                for k, v in raw.items() if k not in self.CONTACT_FIELDS
            }

        return raw
    def _full_event_data(self, fields=None):
        raw = {
            'email': self.CLIENT_MAIL,
            'owner': self.OWNER_MAIL,
            'contactId': self.CONTACT_ID,
            'eventDate': self.EVENT_DATE,
            'contactExtEventType': random.choice(self.VALID_EVENTS),
            'forceOptIn': tests_utils.gen_true_false(),
            'description': tests_utils.gen_string(random.randint(4, 120)),
            'products': tests_utils.gen_string(random.randint(4, 120)),
            'location': tests_utils.gen_string(random.randint(4, 120)),
            'value': random.randint(10, 10000),
            'detail1': tests_utils.gen_string(random.randint(4, 120)),
            'detail2': tests_utils.gen_string(random.randint(4, 120)),
            'externalId': tests_utils.gen_string(random.randint(4, 120)),
            'shopDomain': tests_utils.gen_string(random.randint(4, 120))
        }

        if fields:
            raw = {k: v for k, v in raw.items() if k in fields}

        return raw
 def test_generate_request_payload_addContactExtEvent_accepts_valid_request_type(self) -> None:
     with self.assertRaises(ValueError):
         for x in range(0,10):
             self.clientClass._generate_payload({}, tests_utils.gen_string(12))