tests: switch to py.test, convert sms tests

This commit is contained in:
Frédéric Péters 2015-04-03 22:05:57 +02:00
parent 04fc52c2c6
commit 74f1bbf43b
4 changed files with 21 additions and 22 deletions

9
README
View File

@ -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
========

View File

@ -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'])

1
tests/settings.py Normal file
View File

@ -0,0 +1 @@
LANGUAGE_CODE = 'en-us'

11
tests/test_sms.py Normal file
View File

@ -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']