tests: switch to py.test, convert sms tests
This commit is contained in:
parent
04fc52c2c6
commit
74f1bbf43b
9
README
9
README
|
@ -50,6 +50,15 @@ local_settings.py file set in the same directory, or by a file referenced
|
|||
in the PASSERELLE_SETTINGS_FILE environment variable.
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
Unit tests are written using py.test, and its pytest-django support library.
|
||||
|
||||
DJANGO_SETTINGS_MODULE=passerelle.settings \
|
||||
PASSERELLE_SETTINGS_FILE=tests/settings.py \
|
||||
py.test tests/
|
||||
|
||||
LICENSES
|
||||
========
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.db import transaction
|
||||
|
||||
from . import SMSGatewayMixin
|
||||
|
||||
class MessageTestCase(TestCase):
|
||||
def test_clean_numbers(self):
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['+ 33 12'], '33'),
|
||||
['+3312'])
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['0 0 33 12'], '33'),
|
||||
['+3312'])
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['0 12'], '33'),
|
||||
['+3312'])
|
||||
|
||||
def test_clean_numbers_no_prefix(self):
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['+ 33 12'], '33', prefix=''),
|
||||
['3312'])
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['0 0 33 12'], '33', prefix=''),
|
||||
['3312'])
|
||||
self.assertEqual(SMSGatewayMixin.clean_numbers(['0 12'], '33', prefix=''),
|
||||
['3312'])
|
|
@ -0,0 +1 @@
|
|||
LANGUAGE_CODE = 'en-us'
|
|
@ -0,0 +1,11 @@
|
|||
from passerelle.sms import SMSGatewayMixin
|
||||
|
||||
def test_clean_numbers():
|
||||
assert SMSGatewayMixin.clean_numbers(['+ 33 12'], '33') == ['+3312']
|
||||
assert SMSGatewayMixin.clean_numbers(['0 0 33 12'], '33') == ['+3312']
|
||||
assert SMSGatewayMixin.clean_numbers(['0 12'], '33') == ['+3312']
|
||||
|
||||
def test_clean_numbers_no_prefix():
|
||||
assert SMSGatewayMixin.clean_numbers(['+ 33 12'], '33', prefix='') == ['3312']
|
||||
assert SMSGatewayMixin.clean_numbers(['0 0 33 12'], '33', prefix='') == ['3312']
|
||||
assert SMSGatewayMixin.clean_numbers(['0 12'], '33', prefix='') == ['3312']
|
Loading…
Reference in New Issue