示例#1
0
    def setUp(self):
        self.co_master = SMVETreeCOMaseterFactory()
        self.di = self.co_master.dis[0]
        self.di.tag = 'E0AABBCC'
        self.di.description = 'Equipo de prueba'

        # Texto del evento
        self.timestamp = datetime(2014, 1, 1, 1, 1, 1)
        self.value0 = 0
        EventDescriptionFactory(
            profile=self.co_master.profile,
            textoev2=self.di.idtextoev2,
            value=self.value0,
            text="DESCONECTADO",
        )

        self.user = UserFactory(username='******')
        profile = self.user.get_profile()
        profile.cellphone = '+12345678'
        profile.save()

        self.assoc = SMSNotificationAssociationFactory()
        self.assoc.targets.add(self.user)
        self.assoc.source_di.add(self.di)
示例#2
0
class TestUserProfileShowsInternationalNumbers(WebTest):
    def setUp(self):
        self.user = UserFactory(username="******", is_superuser=True, is_staff=True)
        self.user1 = UserFactory(username="******")
        self.url = reverse('admin:auth_user_change', args=(self.user1.pk, ))

    def test_phonenumber_is_validated(self):
        from apps.hmi.models import UserProfile
        response = self.app.get(self.url, user=self.user)
        response.form.fields['userprofile_set-0-cellphone'] = '123'
        response.showbrowser()

        response = response.form.submit('_save').follow()
        profile = self.user1.get_profile()
        assert False
示例#3
0
class TestNotificationRequestsCreation(TestCase):
    def setUp(self):
        self.co_master = SMVETreeCOMaseterFactory()
        self.di = self.co_master.dis[0]
        self.di.tag = 'E0AABBCC'
        self.di.description = 'Equipo de prueba'

        # Texto del evento
        self.timestamp = datetime(2014, 1, 1, 1, 1, 1)
        self.value0 = 0
        EventDescriptionFactory(
            profile=self.co_master.profile,
            textoev2=self.di.idtextoev2,
            value=self.value0,
            text="DESCONECTADO",
        )

        self.user = UserFactory(username='******')
        profile = self.user.get_profile()
        profile.cellphone = '+12345678'
        profile.save()

        self.assoc = SMSNotificationAssociationFactory()
        self.assoc.targets.add(self.user)
        self.assoc.source_di.add(self.di)

    def test_events_are_created(self):
        # Crear un evento
        NotificationRequest.objects.all().delete()

        self.di.events.create(
            timestamp=self.timestamp,
            q=0,
            value=1,
        )
        self.assertEqual(NotificationRequest.objects.count(), 1)
示例#4
0
 def setUp(self):
     self.user = UserFactory(username="******", is_superuser=True, is_staff=True)
     self.user1 = UserFactory(username="******")
     self.url = reverse('admin:auth_user_change', args=(self.user1.pk, ))