Exemple #1
0
    def test_job_create(self):
        """
        Tests the job_create view.
        * Verifies that the view is reachable just by logged in users.
        * Verifies that after filling the form:
          - A new Job is created.
          - A redirection is made.
        """
        user = self._create_user(True, True)
        response = self.client.get(reverse('job_create'))
        self.assertEqual(response.status_code, 302, str(response.status_code))

        result = self.client.login(username=user.username, password='******')
        self.assertEqual(result, True, 'Login process Failed')

        response = self.client.get(reverse('job_create'))
        self.assertEqual(response.status_code, 200, str(response.status_code))

        response = self.client.post(
            reverse('job_create'),
            {'project': self._create_project(user.get_profile()).id,
             'title': random_string_with_length(),
             'description': random_string_with_length(),
             'status': 1,
             'date_due': datetime.date.today()
             }
        )
        self.assertEqual(response.status_code, 302, str(response.status_code))
        self.assertEqual(Job.objects.count(), 1,
                         'job_create view: The job wasn\'t created.')
Exemple #2
0
 def _create_job(user, project):
     """ creates and returns a new job """
     return Job.objects.create(
         posted_by=user,
         project=project,
         title=random_string_with_length(),
         description=random_string_with_length(),
         status=1,
         date_due=datetime.date.today(),
         tags=random_string_with_length(5)
     )
Exemple #3
0
 def _init_profile(user):
     """ initializes and returns the user's profile """
     profile = user.get_profile()
     profile.middle_name = random_string_with_length(5)
     profile.gender = Person.GENDER[0][0]
     profile.comment = 'Nothing to say'
     profile.time_zone = TZ_CHOICES[0][0]
     profile.save()
     return profile
Exemple #4
0
    def test_company_create(self):
        """
        Tests company_create view.
        * Verifies that the view is reachable just by logged in users.
        * Verifies that after filling the form:
          - A new Project is created.
          - A redirection is made.
        """
        user = self._create_user(True, True)
        response = self.client.get(reverse('company_create'))
        self.assertEqual(response.status_code, 302, str(response.status_code))

        result = self.client.login(username=user.username, password='******')
        self.assertEqual(result, True, 'Login process Failed')

        response = self.client.get(reverse('company_create'))
        self.assertEqual(response.status_code, 200, str(response.status_code))

        response = self.client.post(
            reverse('company_create'),
            {'title': random_string_with_length(),
             'short_description': random_string_with_length(),
             'public_description': random_string_with_length(),
             'long_description': random_string_with_length(),
             'payment_description': random_string_with_length(),
             'dissolution_strategy': random_string_with_length(),
             'estimated_total_project_cost': random.randint(10000, 500000),
             'complexity_rating': 'M',
             'percent_prototype_completed': 0,
             'datetime_prototype_completion_anticipated': datetime.datetime.
             now(),
             'datetime_prototype_actually_completed': datetime.datetime.now(),
             'looking_for_developers': 'Y',
             'open_or_closed': 'O',
             'project_status_history': random_string_with_length(),
             }
        )
        self.assertEqual(response.status_code, 302, str(response.status_code))
        self.assertEqual(Project.objects.count(), 1,
                         'company_create view: The project wasn\'t created.')
Exemple #5
0
 def _create_project(person, title=''):
     """ creates and returns a new project """
     return Project.objects.create(
         title=title or random_string_with_length(),
         short_description=random_string_with_length(),
         public_description=random_string_with_length(),
         long_description=random_string_with_length(),
         payment_description=random_string_with_length(),
         dissolution_strategy=random_string_with_length(),
         estimated_total_project_cost=random.randint(10000, 500000),
         complexity_rating='M',
         percent_prototype_completed=0,
         datetime_prototype_completion_anticipated=datetime.datetime.now(),
         datetime_prototype_actually_completed=datetime.datetime.now(),
         looking_for_developers='Y',
         open_or_closed='O',
         person=person
     )