예제 #1
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
 def test_viewed_incoming_message_decreases_unread_msg_count(self):
     self.assertEquals(1, len(self.acc2.messages.unread))
     self.c.login(email='*****@*****.**', password='******')
     with patch_settings(TASKS_ENABLED={}):
         resp = self.c.get(reverse('user_messages:view_message',
                 kwargs={'message_id': self.msg.id }))
     self.assertEquals(0, len(self.acc2.messages.unread))
예제 #2
0
파일: tests.py 프로젝트: dgk/modnoemesto
 def test_viewed_sent_message_remains_unread(self):
     with patch_settings(TASKS_ENABLED={}):
         resp = self.c.get(
             reverse(
                 'user_messages:view_message',
                 kwargs={'message_id': self.acc2.messages.incoming[0].id}))
     self.msg.reload()
     self.assertFalse(self.msg.is_read)
예제 #3
0
파일: tests.py 프로젝트: dgk/modnoemesto
 def test_viewed_incoming_message_decreases_unread_msg_count(self):
     self.assertEquals(1, len(self.acc2.messages.unread))
     self.c.login(email='*****@*****.**', password='******')
     with patch_settings(TASKS_ENABLED={}):
         resp = self.c.get(
             reverse('user_messages:view_message',
                     kwargs={'message_id': self.msg.id}))
     self.assertEquals(0, len(self.acc2.messages.unread))
예제 #4
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
    def test_viewed_incoming_message_marks_as_read(self):
        self.c.login(email='*****@*****.**', password='******')
        with patch_settings(TASKS_ENABLED={}):
            resp = self.c.get(reverse('user_messages:view_message',
                                  kwargs={'message_id': self.msg.id }))
        msg = self.msg
        msg.reload()

        self.failUnless(msg.readed)
        self.failUnless(msg.is_read)
예제 #5
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
    def test_message_store_read_task(self):
        user1, user2 = self.acc1, self.acc2
        text = 'zzZZzz'
        msg = Message.send(sender=user1, recipient=user2, text=text)

        with patch_settings(TASKS_ENABLED={Message.TASK_NAME_STORE_READED: True}):
            msg.set_readed()
        sleep(1)

        self.failUnless(msg in user2.messages.incoming)
        self.failIf(msg in user2.messages.unread)
예제 #6
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
    def test_message_read(self):
        user1, user2 = self.acc1, self.acc2
        text = 'zzZZzz'
        msg = Message.send(sender=user1, recipient=user2, text=text)

        with patch_settings(TASKS_ENABLED={}):
            msg.set_readed()

        self.failUnless(msg in user2.messages.incoming)
        self.failIf(msg in user2.messages.unread)
        self.failUnless(msg.is_read)
예제 #7
0
파일: tests.py 프로젝트: dgk/modnoemesto
    def test_message_read(self):
        user1, user2 = self.acc1, self.acc2
        text = 'zzZZzz'
        msg = Message.send(sender=user1, recipient=user2, text=text)

        with patch_settings(TASKS_ENABLED={}):
            msg.set_readed()

        self.failUnless(msg in user2.messages.incoming)
        self.failIf(msg in user2.messages.unread)
        self.failUnless(msg.is_read)
예제 #8
0
파일: tests.py 프로젝트: dgk/modnoemesto
    def test_viewed_incoming_message_marks_as_read(self):
        self.c.login(email='*****@*****.**', password='******')
        with patch_settings(TASKS_ENABLED={}):
            resp = self.c.get(
                reverse('user_messages:view_message',
                        kwargs={'message_id': self.msg.id}))
        msg = self.msg
        msg.reload()

        self.failUnless(msg.readed)
        self.failUnless(msg.is_read)
예제 #9
0
파일: tests.py 프로젝트: dgk/modnoemesto
    def test_message_store_read_task(self):
        user1, user2 = self.acc1, self.acc2
        text = 'zzZZzz'
        msg = Message.send(sender=user1, recipient=user2, text=text)

        with patch_settings(
                TASKS_ENABLED={Message.TASK_NAME_STORE_READED: True}):
            msg.set_readed()
        sleep(1)

        self.failUnless(msg in user2.messages.incoming)
        self.failIf(msg in user2.messages.unread)
예제 #10
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
    def test_message_delete(self):
        with patch_settings(TASKS_ENABLED={}):
            user1, user2 = self.acc1, self.acc2
            text = 'zzZZzz'
            msg = Message.send(sender=user1, recipient=user2, text=text)

            self.failUnless(msg in user1.messages.sent)
            self.failUnless(msg in user2.messages.incoming)
            self.failUnless(msg in user2.messages.unread)

            msg.set_user_delete(user1)

            self.failIf(msg in user1.messages.sent)
            self.failUnless(msg in user2.messages.incoming)
            self.failUnless(msg in user2.messages.unread)

            msg.set_user_delete(user2)
            self.failIf(msg in user1.messages.sent)
            self.failIf(msg in user2.messages.incoming)
            self.failIf(msg in user2.messages.unread)
예제 #11
0
파일: tests.py 프로젝트: dgk/modnoemesto
    def test_message_delete(self):
        with patch_settings(TASKS_ENABLED={}):
            user1, user2 = self.acc1, self.acc2
            text = 'zzZZzz'
            msg = Message.send(sender=user1, recipient=user2, text=text)

            self.failUnless(msg in user1.messages.sent)
            self.failUnless(msg in user2.messages.incoming)
            self.failUnless(msg in user2.messages.unread)

            msg.set_user_delete(user1)

            self.failIf(msg in user1.messages.sent)
            self.failUnless(msg in user2.messages.incoming)
            self.failUnless(msg in user2.messages.unread)

            msg.set_user_delete(user2)
            self.failIf(msg in user1.messages.sent)
            self.failIf(msg in user2.messages.incoming)
            self.failIf(msg in user2.messages.unread)
예제 #12
0
    def handle(self, *args, **options):
        num = int(args and args[0] or 10)
        with_ava = len(args) > 1

        for type in (documents.User, Message, FriendshipOffer, UserFriends, GroupUser):
            type.objects.delete()

        if with_ava:
            if not os.path.exists("faces94"):
                raise CommandError(
                    "faces database not exists, do\n"
                    "wget http://cswww.essex.ac.uk/mv/allfaces/faces94.zip && unzip faces94.zip"
                )

            faces = []

            def visit(arg, dirname, names):
                if len(re.split("/", dirname)) != 3:
                    return
                faces.append(os.path.join(dirname, random.choice(names)))

            os.path.walk("faces94", visit, None)
            random.shuffle(faces)

        # creating accounts
        male_first_names = u"""
        Сергей
        Александр
        Дмитрий
        Андрей
        Артур
        Игорь
        Армен
        Алексей
        Григорий
        """.split()

        female_first_names = u"""
        Анна
        Анастасия
        Риана
        Елена
        Мария
        Дарина
        Кристина
        Марина
        Ангелина
        Полина
        """.split()

        male_last_names = u"""
        Смирнов
        Иванов
        Кузнецов
        Соколов
        Попов
        Лебедев
        Козлов
        Новиков
        Морозов
        Петров
        Волков
        Соловьёв
        Васильев
        Зайцев
        Павлов
        Семёнов
        Голубев
        Виноградов
        Богданов
        Воробьёв
        Фёдоров
        Михайлов
        Беляев
        Тарасов
        """.split()

        female_last_names = [u"%sа" % x for x in male_last_names]

        male_names = (male_first_names, male_last_names)
        female_names = (female_first_names, female_last_names)

        print
        for i in xrange(num):
            if not i % (num / 10 or 10):
                print "\rusers creation %002d%%" % (i * 100 / num)
                sys.stdout.flush()
            if with_ava:
                if faces[i].find("/female/") != -1:
                    names = female_names
                else:
                    names = male_names
            else:
                names = random.choice((male_names, female_names))

            first_name = random.choice(names[0])
            last_name = random.choice(names[1])

            email = "*****@*****.**" % i

            acc = documents.User.create_user(
                first_name=first_name, last_name=last_name, email=email, password="******", is_superuser=bool(not i)
            )
            acc.save()
            if with_ava:
                client = Client()
                client.login(email=email, password="******")
                file = open(faces[i])
                with patch_settings(TASKS_ENABLED={}):
                    client.post(reverse("social:avatar_edit"), {"file": file})

        print "\rusers creation 100%"
        # friending & messaging
        print
        for i in xrange(num):
            max_friends_count = random.randint(0, num % 25 + 25)
            friends_numbers = set([random.randint(0, num - 1) for _ in xrange(max_friends_count)]).difference(set([i]))
            this_user = documents.User.objects().order_by("username")[i]

            for fn in friends_numbers:
                friend = documents.User.objects().order_by("username")[fn]
                # this_user.reload()
                this_user.friends.offers.send(friend)
                random.randint(0, 3) and friend.friends.offers.send(this_user)  # ~66%

            max_msg_sndrs_count = random.randint(0, num)
            msg_sndrs_numbers = set([random.randint(0, num - 1) for _ in xrange(max_msg_sndrs_count)]).difference(
                set([i])
            )

            for sndr_num in msg_sndrs_numbers:
                messages_count = random.randint(0, 3)

                sndr = documents.User.objects().order_by("username")[sndr_num]
                for _ in xrange(messages_count):
                    Message.send(sndr, this_user, lorem_ipsum.paragraph())

            if not i % (num / 10 or 10):
                print "\rfriending and messaging %002d%%" % (i * 100 / num),
                sys.stdout.flush()
        print "\rfriending and messaging 100%"
        print

        CameraType(name="Axis only view", driver="apps.cam.drivers.axis.AxisDriver").save()
        CameraType(name="Axis manage", driver="apps.cam.drivers.axis.AxisDriver", is_controlled=True).save()
        print "\rCemeras 100%"
        print

        Tariff(
            name="View Package 1 min",
            description="View Package Description...",
            cost=1.0,
            duration=60.0,
            is_controlled=False,
        ).save()
        Tariff(
            name="View Package Time", description="View Package Description...", cost=1.0, is_controlled=False
        ).save()
        Tariff(
            name="Manage Package 1 min",
            description="Manage Package Description...",
            cost=2.0,
            duration=60.0,
            is_controlled=True,
        ).save()
        Tariff(
            name="Manage Package Time", description="Manage Package Description...", cost=2.0, is_controlled=True
        ).save()
        print "\rTariffs 100%"
예제 #13
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
 def run(self, *args, **kwargs):
     with patch_settings(MAX_USER_MESSAGES_COUNT=self.MAX_MESSAGES_COUNT):
         result = super(MassMessagingTestCase, self).run(*args, **kwargs)
     return result
예제 #14
0
파일: tests.py 프로젝트: Rudy24/modnoemesto
 def test_viewed_sent_message_remains_unread(self):
     with patch_settings(TASKS_ENABLED={}):
         resp = self.c.get(reverse('user_messages:view_message',
               kwargs={'message_id': self.acc2.messages.incoming[0].id }))
     self.msg.reload()
     self.assertFalse(self.msg.is_read)
예제 #15
0
파일: tests.py 프로젝트: dgk/modnoemesto
 def run(self, *args, **kwargs):
     with patch_settings(MAX_USER_MESSAGES_COUNT=self.MAX_MESSAGES_COUNT):
         result = super(MassMessagingTestCase, self).run(*args, **kwargs)
     return result
예제 #16
0
    def handle(self, *args, **options):
        num = int(args and args[0] or 10)
        with_ava = len(args) > 1

        for type in (
                documents.User,
                Message,
                FriendshipOffer,
                UserFriends,
                GroupUser,
        ):
            type.objects.delete()

        if with_ava:
            if not os.path.exists('faces94'):
                raise CommandError(
                    'faces database not exists, do\n'
                    'wget http://cswww.essex.ac.uk/mv/allfaces/faces94.zip && unzip faces94.zip'
                )

            faces = []

            def visit(arg, dirname, names):
                if len(re.split('/', dirname)) != 3:
                    return
                faces.append(os.path.join(dirname, random.choice(names)))

            os.path.walk('faces94', visit, None)
            random.shuffle(faces)

        # creating accounts
        male_first_names = u'''
        Сергей
        Александр
        Дмитрий
        Андрей
        Артур
        Игорь
        Армен
        Алексей
        Григорий
        '''.split()

        female_first_names = u'''
        Анна
        Анастасия
        Риана
        Елена
        Мария
        Дарина
        Кристина
        Марина
        Ангелина
        Полина
        '''.split()

        male_last_names = u'''
        Смирнов
        Иванов
        Кузнецов
        Соколов
        Попов
        Лебедев
        Козлов
        Новиков
        Морозов
        Петров
        Волков
        Соловьёв
        Васильев
        Зайцев
        Павлов
        Семёнов
        Голубев
        Виноградов
        Богданов
        Воробьёв
        Фёдоров
        Михайлов
        Беляев
        Тарасов
        '''.split()

        female_last_names = [u'%sа' % x for x in male_last_names]

        male_names = (male_first_names, male_last_names)
        female_names = (female_first_names, female_last_names)

        print
        for i in xrange(num):
            if not i % (num / 10 or 10):
                print '\rusers creation %002d%%' % (i * 100 / num)
                sys.stdout.flush()
            if with_ava:
                if faces[i].find('/female/') != -1:
                    names = female_names
                else:
                    names = male_names
            else:
                names = random.choice((male_names, female_names))

            first_name = random.choice(names[0])
            last_name = random.choice(names[1])

            email = '*****@*****.**' % i

            acc = documents.User.create_user(first_name=first_name,
                                             last_name=last_name,
                                             email=email,
                                             password='******',
                                             is_superuser=bool(not i))
            acc.save()
            if with_ava:
                client = Client()
                client.login(email=email, password='******')
                file = open(faces[i])
                with patch_settings(TASKS_ENABLED={}):
                    client.post(reverse('social:avatar_edit'), {'file': file})

        print '\rusers creation 100%'
        # friending & messaging
        print
        for i in xrange(num):
            max_friends_count = random.randint(0, num % 25 + 25)
            friends_numbers = set([
                random.randint(0, num - 1) for _ in xrange(max_friends_count)
            ]).difference(set([i]))
            this_user = documents.User.objects().order_by('username')[i]

            for fn in friends_numbers:
                friend = documents.User.objects().order_by('username')[fn]
                #this_user.reload()
                this_user.friends.offers.send(friend)
                random.randint(0, 3) and friend.friends.offers.send(
                    this_user)  # ~66%

            max_msg_sndrs_count = random.randint(0, num)
            msg_sndrs_numbers = set([
                random.randint(0, num - 1) for _ in xrange(max_msg_sndrs_count)
            ]).difference(set([i]))

            for sndr_num in msg_sndrs_numbers:
                messages_count = random.randint(0, 3)

                sndr = documents.User.objects().order_by('username')[sndr_num]
                for _ in xrange(messages_count):
                    Message.send(sndr, this_user, lorem_ipsum.paragraph())

            if not i % (num / 10 or 10):
                print '\rfriending and messaging %002d%%' % (i * 100 / num),
                sys.stdout.flush()
        print '\rfriending and messaging 100%'
        print

        CameraType(
            name='Axis only view',
            driver='apps.cam.drivers.axis.AxisDriver',
        ).save()
        CameraType(
            name='Axis manage',
            driver='apps.cam.drivers.axis.AxisDriver',
            is_controlled=True,
        ).save()
        print '\rCemeras 100%'
        print

        Tariff(
            name='View Package 1 min',
            description='View Package Description...',
            cost=1.0,
            duration=60.0,
            is_controlled=False,
        ).save()
        Tariff(
            name='View Package Time',
            description='View Package Description...',
            cost=1.0,
            is_controlled=False,
        ).save()
        Tariff(
            name='Manage Package 1 min',
            description='Manage Package Description...',
            cost=2.0,
            duration=60.0,
            is_controlled=True,
        ).save()
        Tariff(
            name='Manage Package Time',
            description='Manage Package Description...',
            cost=2.0,
            is_controlled=True,
        ).save()
        print '\rTariffs 100%'