Exemplo n.º 1
0
 def setUp(self):
     super().setUp()
     user = UserFactory(username='******')
     self.worker = WorkerFactory(user=user)
     self.request_client.login(username=self.worker.user.username,
                               password='******')
     self.time = timezone.now()
Exemplo n.º 2
0
 def authenticate_user(self):
     password = '******'
     auth_user = UserFactory(
         username='******',
         email='*****@*****.**',
         first_name='first name',
         last_name='last name',
         is_active=True,
         password=password)
     self.assertTrue(self.request_client.login(
         username=auth_user.username, password=password))
     return auth_user
Exemplo n.º 3
0
    def setUp(self):
        super().setUp()
        setup_models(self)
        self.project_admin_group = Group.objects.create(name='project_admins')
        user = (UserFactory(username='******',
                            first_name='project_management',
                            last_name='project_management',
                            password='******',
                            email='*****@*****.**'))
        self.worker = WorkerFactory(user=user)
        user.groups.add(self.project_admin_group)

        self.api_client = Client()
        self.api_client.login(username='******',
                              password='******')
Exemplo n.º 4
0
    def setUp(self):
        self.workflow_old = WorkflowFactory(
            slug='workflow_old',
            name='Old workflow',
            description='Old workflow to migrate certifications from.',
            code_directory='workflow_old')
        self.workflow_new = WorkflowFactory(
            slug='workflow_new',
            name='New workflow',
            description='New workflow to migrate certifications from.',
            code_directory='workflow_new')

        for workflow in (self.workflow_old, self.workflow_new):
            # Certifications must exist in both workflows for certification
            # to be migrated
            CertificationFactory(
                slug='certification1',
                name='Certification 1',
                description='First certification to migrate.',
                workflow=workflow)
            CertificationFactory(
                slug='certification2',
                name='Certification 2',
                description='Second certification to migrate.',
                workflow=workflow)

        user = (UserFactory(username='******',
                            first_name='test',
                            last_name='test',
                            password='******',
                            email='*****@*****.**'))
        self.worker = WorkerFactory(user=user)

        for certification in self.workflow_old.certifications.all():
            # Worker certifications exist only for old workflow
            WorkerCertificationFactory(
                worker=self.worker,
                certification=certification,
                role=WorkerCertification.Role.ENTRY_LEVEL)
            WorkerCertificationFactory(
                worker=self.worker,
                certification=certification,
                role=WorkerCertification.Role.REVIEWER)

        super().setUp()
Exemplo n.º 5
0
    def test_worker_autocreation(self):
        """ When new users register, worker objects should be autocreated. """

        # Create a user
        user = UserFactory(username='******',
                           password='******',
                           email='*****@*****.**')

        # There should be no worker yet
        self.assertFalse(Worker.objects.filter(user=user).exists())

        # Fake registering the user
        user_registered.send(sender=self.__class__, user=user, request=None)

        # Expect the worker object to be created
        self.assertTrue(
            Worker.objects.filter(user=user).exists(),
            'Worker not autocreated on User registration')
Exemplo n.º 6
0
 def setUp(self):
     super().setUp()
     project = ProjectFactory()
     step = StepFactory()
     self.old_title = 'Old title'
     self.new_title = 'New title'
     self.old_details = 'Old details'
     self.new_details = 'New details'
     self.old_todo = TodoFactory(title=self.old_title,
                                 details=self.old_details,
                                 completed=False,
                                 project=project,
                                 step=step)
     self.new_todo = TodoFactory(title=self.new_title,
                                 details=self.new_details,
                                 completed=True,
                                 project=project,
                                 step=step)
     self.sender = UserFactory()
Exemplo n.º 7
0
 def setUp(self):
     self.user = UserFactory()
     self.worker = WorkerFactory(user=self.user)
     super().setUp()