コード例 #1
0
    def test_saving_and_retrieving_vacancies(self):
        username1 = '*****@*****.**'
        password = '******'
        user1 = User.objects.create_user(username1, password)
        first_vacancy = Vacancy()
        first_vacancy.user = user1
        first_vacancy.employer = self.employer
        first_vacancy.title = 'Welder TIG'
        first_vacancy.salary_min = 50000
        first_vacancy.save()

        second_vacancy = Vacancy()
        username2 = '*****@*****.**'
        password = '******'
        user2 = User.objects.create_user(username2, password)
        second_vacancy.user = user2
        second_vacancy.employer = self.employer
        second_vacancy.title = "Welder MIG-MAG"
        second_vacancy.salary_min = 60000
        second_vacancy.save()

        saved_vacancies = Vacancy.objects.all()
        self.assertEqual(saved_vacancies.count(), 2)

        first_saved_vacancy = saved_vacancies[0]
        second_saved_vacancy = saved_vacancies[1]
        self.assertEqual(first_saved_vacancy.title, 'Welder TIG')
        self.assertEqual(second_saved_vacancy.title, 'Welder MIG-MAG')
コード例 #2
0
    def test_get_vacancy_count(self):
        username1 = '*****@*****.**'
        password = '******'
        user1 = User.objects.create_user(username1, password)
        first_vacancy = Vacancy()
        first_vacancy.user = user1
        first_vacancy.employer = self.employer_1
        first_vacancy.title = 'Welder TIG'
        first_vacancy.salary_min = 50000
        first_vacancy.save()

        second_vacancy = Vacancy()
        username2 = '*****@*****.**'
        password = '******'
        user2 = User.objects.create_user(username2, password)
        second_vacancy.user = user2
        second_vacancy.employer = self.employer_1
        second_vacancy.title = "Welder MIG-MAG"
        second_vacancy.salary_min = 60000
        second_vacancy.save()

        self.assertEqual(2, self.employer_1.get_vacancy_count())