def test_build_query_params(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') query = m._parse_filter_ordering( filter_by='Name.Contains(\'Farmacie\')', order_by=['Name asc', 'idGroup desc']) assert query == 'filterby=Name.Contains%28%27Farmacie%27%29&orderby=Name+asc%3BidGroup+desc' query = m._parse_filter_ordering( filter_by='Name.Contains(\'Farmacie\')') assert query == 'filterby=Name.Contains%28%27Farmacie%27%29' query = m._parse_filter_ordering(order_by=['Name asc', 'idGroup desc']) assert query == 'orderby=Name+asc%3BidGroup+desc'
def test_get_fields(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert list(m.get_fields())[0]['Id'] == 27
def test_refresh_token(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') m._token = 'bad_token' list(m.get_fields()) assert m._token == 'good_token'
def test_unsubscribe_from_group(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.unsubscribe_from_group(6, 18)
def test_remove_from_list(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.remove_from_list(1, 18)
def test_subscribe_to_group(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.subscribe_to_group(6, 'ASDFGHJKL', '*****@*****.**', {'test': 'test'}) == 18
def test_update_customer_fields(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.update_customer_fields('ASDFGHJKL', '*****@*****.**', {'test': 'test1'})['idRecipient'] == 18
def test_create_group(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.create_group(1, 'TEST')['idGroup'] == 9
def test_subscribe_to_list_pending(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.subscribe_to_list(1, 'ASDFGHJKL', '*****@*****.**', pending=True) == 16
def test_get_message_by_tags(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert list(m.get_messages_from_list(1, ''))[0]['Subject'] == 'QWERTYUIOP'
def test_send_message(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.send_message('*****@*****.**', 1)
def test_get_recipients_from_group(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert list(m.get_recipients_from_group(6)) == []
def test_get_recipients_from_list(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert list(m.get_recipients_from_list(1))[0]['idRecipient'] == 13
def test_get_groups_from_list(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert list(m.get_groups_from_list(1))[0]['idGroup'] == 6
def test_raise_exception_on_requests_exception(self, func): with self.assertRaises(MailupyException) as ex: m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.remove_from_list(1, 18)
def test_send_message(self, func): m = Mailupy('username', 'password', 'client-id', 'client-secret') assert m.send_sms('+39','0000000000', 1)