Beispiel #1
0
    def test_get_bids_no_bids(self):
        bob = JobPoster.objects.get(name="Bob")

        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        self.assertEquals(0, len(post.get_bids(bob, posting.pk)))
Beispiel #2
0
    def test_delete_job_posting_wrong_owner(self):
        bob = JobPoster.objects.get(name="Bob")
        frank = JobPoster.objects.get(name="Frank")
        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        with self.assertRaises(PermissionDenied):
            post.delete_job_posting(frank, posting.pk)
Beispiel #3
0
    def test_delete_job_posting(self):
        bob = JobPoster.objects.get(name="Bob")
        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        post.delete_job_posting(bob, posting.pk)

        self.assertEquals(0, len(bob.jobposting_set.all()))
Beispiel #4
0
    def test_update_job_posting(self):
        bob = JobPoster.objects.get(name="Bob")
        posting = new_job_posting(description="old description")
        post.create_job_posting(bob, posting)

        posting.description = "new_description"
        post.update_job_posting(bob, posting)

        self.assertEquals("new_description",
                          bob.jobposting_set.get().description)
Beispiel #5
0
    def test_rate_contractor_job_not_completed(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")

        posting = new_job_posting(contractor=emily)
        post.create_job_posting(bob, posting)

        with self.assertRaises(PermissionDenied):
            post.rate_contractor(bob, emily, 5)

        self.assertEquals(0, len(emily.contractorrating_set.all()))
Beispiel #6
0
    def test_rate_contractor(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")

        posting = new_job_posting(contractor=emily,
                                  completed=True,
                                  completion_date=now())
        post.create_job_posting(bob, posting)

        post.rate_contractor(bob, emily, 5)
        self.assertEquals(5, emily.contractorrating_set.get(poster=bob).rating)
Beispiel #7
0
    def test_update_job_posting_wrong_owner(self):
        bob = JobPoster.objects.get(name="Bob")
        frank = JobPoster.objects.get(name="Frank")
        posting = new_job_posting(description="old_description")
        post.create_job_posting(bob, posting)

        posting.description = "new_description"
        with self.assertRaises(PermissionDenied):
            post.update_job_posting(frank, posting)

        self.assertEquals("old_description",
                          bob.jobposting_set.get().description)
Beispiel #8
0
    def test_accept_bid_wrong_owner(self):
        bob = JobPoster.objects.get(name="Bob")
        frank = JobPoster.objects.get(name="Frank")
        emily = Contractor.objects.get(name="Emily")

        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        bid = Bid(contractor=emily, job=posting)
        bid.save()

        with self.assertRaises(PermissionDenied):
            post.accept_bid(frank, bid.pk)

        self.assertEquals(bob.jobposting_set.get().contractor, None)
Beispiel #9
0
    def test_get_bids_wrong_owner(self):
        bob = JobPoster.objects.get(name="Bob")
        frank = JobPoster.objects.get(name="Frank")
        emily = Contractor.objects.get(name="Emily")
        joseph = Contractor.objects.get(name="Joseph")

        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        bid1 = Bid(contractor=emily, job=posting)
        bid2 = Bid(contractor=joseph, job=posting)
        bid1.save()
        bid2.save()

        with self.assertRaises(PermissionDenied):
            post.get_bids(frank, posting.pk)
Beispiel #10
0
    def test_accept_bid(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")
        joseph = Contractor.objects.get(name="Joseph")

        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        bid1 = Bid(contractor=emily, job=posting)
        bid2 = Bid(contractor=joseph, job=posting)
        bid1.save()
        bid2.save()

        post.accept_bid(bob, bid1.pk)

        self.assertEquals(bob.jobposting_set.get().contractor, emily)
        self.assertEquals(0, len(posting.bid_set.all()))
Beispiel #11
0
    def test_get_bids(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")
        joseph = Contractor.objects.get(name="Joseph")

        posting1 = new_job_posting()
        posting2 = new_job_posting()
        post.create_job_posting(bob, posting1)
        post.create_job_posting(bob, posting2)

        bid1 = Bid(contractor=emily, job=posting1)
        bid2 = Bid(contractor=joseph, job=posting1)
        bid3 = Bid(contractor=emily, job=posting2)

        bid1.save()
        bid2.save()
        bid3.save()

        self.assertEquals({bid1, bid2}, set(post.get_bids(bob, posting1.pk)))
Beispiel #12
0
    def test_get_active_jobs(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")
        joseph = Contractor.objects.get(name="Joseph")

        active1 = new_job_posting(contractor=emily)
        active2 = new_job_posting(contractor=joseph)

        posting = new_job_posting()

        completed = new_job_posting(contractor=emily,
                                    completed=True,
                                    completion_date=now())

        post.create_job_posting(bob, active1)
        post.create_job_posting(bob, active2)
        post.create_job_posting(bob, posting)
        post.create_job_posting(bob, completed)

        self.assertEquals({active1, active2}, set(post.get_active_jobs(bob)))
Beispiel #13
0
    def test_get_job_postings(self):
        bob = JobPoster.objects.get(name="Bob")
        emily = Contractor.objects.get(name="Emily")

        posting1 = new_job_posting()
        posting2 = new_job_posting()

        active = new_job_posting(short_description="active", contractor=emily)
        completed = new_job_posting(short_description="completed",
                                    contractor=emily,
                                    completed=True,
                                    completion_date=now())

        post.create_job_posting(bob, posting1)
        post.create_job_posting(bob, posting2)
        post.create_job_posting(bob, active)
        post.create_job_posting(bob, completed)

        self.assertEquals({posting1, posting2},
                          set(post.get_job_postings(bob)))
Beispiel #14
0
 def test_create_job_posting_field_too_long(self):
     with self.assertRaises(SuspiciousOperation):
         bob = JobPoster.objects.get(name="Bob")
         posting = new_job_posting(short_description="toolong" * 50)
         post.create_job_posting(bob, posting)
Beispiel #15
0
 def test_create_job_posting_missing_required_field(self):
     with self.assertRaises(SuspiciousOperation):
         bob = JobPoster.objects.get(name="Bob")
         posting = new_job_posting(description=None)
         post.create_job_posting(bob, posting)
Beispiel #16
0
    def test_create_job_posting(self):
        bob = JobPoster.objects.get(name="Bob")
        posting = new_job_posting()
        post.create_job_posting(bob, posting)

        self.assertTrue(posting in bob.jobposting_set.all())