Exemple #1
0
    def test_generate_data_helper(self):
        init_roles()

        UserProfileGenerator().generate(UserProfileGenerator.MANAGER, num=2)
        UserProfileGenerator().generate(UserProfileGenerator.ANIMATOR, num=3)
        UserProfileGenerator().generate(UserProfileGenerator.PHOTOGRAPHER,
                                        num=2)
        ProgramGenerator().generate(5)
        additional_services = AdditionalServicesGenerator().generate()
        DiscountsGenerator().generate()
        ClientGenerator().generate(5)
        OrderGenerator().generate(num_events=10, num_days=45)

        orders = Order.objects.all()

        id_to_service = {}

        for s in additional_services:
            id_to_service.update({s.id: s})

        for order in orders:
            services_executors = order.additional_services_executors.all()
            for line in services_executors:
                self.assertTrue(line.executor.user.id in [
                    i.user.id for i in id_to_service[
                        line.additional_service.id].possible_executors.all()
                ])

            self.assertTrue(len(order.program_executors.all()) > 0)
Exemple #2
0
def _init_client(logged=False, role=None):
    client = Client()
    profile = None
    if logged:
        if not role:
            raise AttributeError('Role is not specified!')
        prof_gen = UserProfileGenerator()
        prof_gen.generate(role)
        profile = UserProfile.objects.filter(user__groups__name=role).first()
        client.login(username=profile.get_username(), password='******')
    return client, profile
Exemple #3
0
    def setUp(self):
        gen_us = UserProfileGenerator()
        gen_us.generate(UserProfileGenerator.ANIMATOR, 4)
        gen_us.generate(UserProfileGenerator.PHOTOGRAPHER, 2)
        gen_serv = AdditionalServicesGenerator()
        gen_serv.generate()

        self.data = {
            'title': 'Супер-пупер сервис',
            'num_executors': 2,
            'possible_executors': UserProfile.objects.all_executors()[:4],
            'price': 555000
        }
Exemple #4
0
    def setUp(self):
        gen_us = UserProfileGenerator()
        gen_us.generate(UserProfileGenerator.ANIMATOR, 4)
        gen_us.generate(UserProfileGenerator.PHOTOGRAPHER, 2)
        gen_prog = ProgramGenerator()
        gen_prog.generate(8)

        self.data = {
            'title': 'Наркоман и Гномик',
            'characters': 'Наркоман, Гномик',
            'num_executors': 2,
            'possible_executors': UserProfile.objects.all_executors()[:4],
        }
Exemple #5
0
 def test_permissions_delete_user_for_anonymous(self):
     client, _ = _init_client()
     profile = UserProfileGenerator().generate(
         role=UserProfileGenerator.MANAGER).pop(0)
     response = client.get(
         reverse('orders_manager:delete_user',
                 kwargs={'username': profile.get_username()}))
     self.assertRedirects(
         response,
         reverse('orders_manager:login') + '?next={}'.format(
             reverse('orders_manager:delete_user',
                     kwargs={'username': profile.get_username()})))
     self.assertEqual(response.status_code, 302)
Exemple #6
0
    def setUp(self):
        from orders_manager.models import UserProfile
        from orders_manager.roles import init_roles

        init_roles()
        gen_us = UserProfileGenerator()
        gen_us.generate(UserProfileGenerator.ANIMATOR, 4)
        user_profiles = UserProfile.objects.all()
        user_profile = UserProfile.objects.first()
        self.day_off_data = {
            'user_id': user_profile.user.id,
            'date': '2015-12-03',
            'time_start': '10:00:00',
            'time_end': '15:00:00'
        }
Exemple #7
0
 def setUp(self):
     init_roles()
     us_gen = UserProfileGenerator()
     us_gen.generate(role=UserProfileGenerator.ANIMATOR, num=5)
     us_gen.generate(role=UserProfileGenerator.MANAGER, num=3)
     us_gen.generate(role=UserProfileGenerator.PHOTOGRAPHER, num=1)
Exemple #8
0
 def setUp(self):
     self.my_profile = UserProfileGenerator().generate(
         role=UserProfileGenerator.MANAGER).pop(0)