Example #1
0
    def test_create_email_with_valid_params_should_format_the_params_correctly(self):
        client = SignaturitClient('TOKEN')

        parser = Parser(client.CREATE_EMAIL_PARAMS, [])

        open(self.TEST_FILE_URL, 'a').close()

        email_params = {'subject': 'Certified email',
                        'body': 'Please, can you check this receipt? Just click the button!',
                        'recipients': [{'email': '*****@*****.**', 'fullname': 'Pau'},
                                       {'email': '*****@*****.**', 'fullname': 'John'}],
                        'files': [self.TEST_FILE_URL]}

        expected_params = {'body': 'Please, can you check this receipt? Just click the button!',
                           'recipients[1][email]': '*****@*****.**',
                           'recipients[0][email]': '*****@*****.**',
                           'recipients[0][fullname]': 'Pau',
                           'recipients[1][fullname]': 'John',
                           'subject': 'Certified email'}

        parsed_data, files = parser.parse_data(email_params)

        self.assertEquals(expected_params, parsed_data)
        self.assertEquals(1, len(files))

        os.unlink(self.TEST_FILE_URL)
    def test_create_signature_with_valid_params_should_format_the_params_correctly(self):
        client = SignaturitClient('TOKEN')
        parser = Parser(client.CREATE_SIGN_PARAMS, [])

        open(self.TEST_FILE_URL, 'a').close()

        sign_params = {'subject': 'Receipt number 215',
                       'in_person_sign': 1,
                       'mandatory_photo': 1,
                       'sequential': 1,
                       'body': 'Please, can you sign this receipt? Just click the button!',
                       'mandatory_pages': [2, 5],
                       'recipients': [{'email': '*****@*****.**', 'fullname': 'Pau'},
                                      {'email': '*****@*****.**', 'fullname': 'John'}],
                       'files': [self.TEST_FILE_URL]}

        expected_params = {'body': 'Please, can you sign this receipt? Just click the button!',
                           'mandatory_pages[0]': '2',
                           'mandatory_photo': '1',
                           'recipients[1][fullname]': 'John',
                           'mandatory_pages[1]': '5',
                           'recipients[1][email]': '*****@*****.**',
                           'sequential': '1',
                           'recipients[0][email]': '*****@*****.**',
                           'recipients[0][fullname]': 'Pau',
                           'in_person_sign': '1',
                           'subject': 'Receipt number 215'}

        parsed_data, files = parser.parse_data(sign_params)

        self.assertEquals(expected_params, parsed_data)
        self.assertEquals(1, len(files))

        os.unlink(self.TEST_FILE_URL)
Example #3
0
    def test_put_branding_should_return_file_but_no_params(self):
        client = SignaturitClient("TOKEN")
        parser = Parser(client.TOUCH_BRANDING_PARAMS, [])

        open(self.TEST_FILE_URL, "a").close()

        params = {"files": self.TEST_FILE_URL}

        params, files = parser.parse_data(params)

        self.assertEquals(1, len(files))
        self.assertEquals(1, len(params))

        os.unlink(self.TEST_FILE_URL)