def setUp(self): password = '******' user = User(username='******') user.set_password(password) user.full_clean() user.save() ut = UserToken(user=user, tokens=1) ut.full_clean() ut.save() company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=user.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job.full_clean() self.job.save() self.client.post('/login/', { 'username': user.username, 'password': password })
def setUp(self): user = User(username='******') user.set_password('password') user.full_clean() user.save() company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=user.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job.full_clean() self.job.save() self.job.activate()
def setUp(self): password = '******' user = User(username='******') user.set_password(password) user.full_clean() user.save() ut = UserToken(user=user, tokens=1) ut.full_clean() ut.save() company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=user.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job.full_clean() self.job.save() self.client.post( '/login/', {'username': user.username, 'password': password} )
class CompanyAuthdViewTests(TestCase): def setUp(self): password = '******' owner = User(username='******') owner.set_password(password) owner.full_clean() owner.save() other = User(username='******') other.set_password(password) other.full_clean() other.save() self.company1 = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=owner.id) self.company1.full_clean() self.company1.save() self.company2 = Company(name='WFH.io', url='https://www.wfh.io', site_id=1, user_id=other.id) self.company2.full_clean() self.company2.save() self.client.post( '/login/', {'username': owner.username, 'password': password} ) def test_index_view(self): response = self.client.get(reverse('companies_index')) self.assertEqual(response.status_code, 200) def test_new_view(self): response = self.client.get(reverse('companies_new')) self.assertEqual(response.status_code, 200) def test_show_view(self): response = self.client.get(self.company1.get_absolute_url()) self.assertEqual(response.status_code, 200) def test_show_view_on_own_company_shows_edit_link(self): response = self.client.get(self.company1.get_absolute_url()) url = reverse('companies_edit', args=(self.company1.id,)) edit = '<a class="btn btn-default btn-sm" ' \ 'href="%s">Edit Company</a>' % url self.assertContains(response, edit) def test_show_view_on_other_company_does_not_show_edit_link(self): response = self.client.get(self.company2.get_absolute_url()) url = reverse('companies_edit', args=(self.company2.id,)) edit = '<a class="btn btn-primary btn-sm" ' \ 'href="%s">Edit Company</a>' % url self.assertNotContains(response, edit) def test_edit_view(self): response = self.client.get( reverse('companies_edit', args=(self.company1.id,)) ) self.assertEqual(response.status_code, 200)
class CompanyMethodTests(TestCase): def setUp(self): self.user = User(username='******') self.user.set_password('password') self.user.full_clean() self.user.save() self.company = Company(name='Tramcar', site_id=1, user_id=self.user.id, url='http://www.tramcar.org') self.company.full_clean() self.company.save() self.category = Category(name='Software Development', site_id=1) self.category.full_clean() self.category.save() def test_active_jobs(self): job = Job(title='Software Developer', description='Test description', application_info='test', category_id=self.category.id, company_id=self.company.id, site_id=1, user_id=self.user.id, city='Toronto', state='Ontario', email='*****@*****.**') job.full_clean() job.save() self.assertEqual(len(self.company.active_jobs()), 0) job.activate() self.assertEqual(len(self.company.active_jobs()), 1) def test_paid_jobs(self): job = Job(title='Software Developer', description='Test description', application_info='test', category_id=self.category.id, company_id=self.company.id, site_id=1, user_id=self.user.id, city='Toronto', state='Ontario', email='*****@*****.**') job.full_clean() job.save() self.assertEqual(len(self.company.paid_jobs()), 0) job.activate() self.assertEqual(len(self.company.paid_jobs()), 1)
def setUp(self): password = '******' admin = User(username='******') admin.is_staff = True admin.set_password(password) admin.full_clean() admin.save() self.other = User(username='******') self.other.set_password(password) self.other.full_clean() self.other.save() country = Country(name='Canada') country.full_clean() country.save() company = Company(name='Tramcar', site_id=1, user_id=self.other.id, url='http://www.tramcar.org') company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=self.other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job.full_clean() self.job.save() self.client.post('/login/', { 'username': admin.username, 'password': password })
class CompanyAdminViewTests(TestCase): def setUp(self): password = '******' owner = User(username='******') owner.set_password(password) owner.full_clean() owner.save() admin = User(username='******') admin.is_staff = True admin.set_password(password) admin.full_clean() admin.save() self.company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=owner.id) self.company.full_clean() self.company.save() self.client.post( '/login/', {'username': admin.username, 'password': password} ) def test_edit_get_view(self): response = self.client.get( reverse('companies_edit', args=(self.company.id,)) ) self.assertEqual(response.status_code, 200) def test_edit_post_view(self): company = { 'name': 'Tramcar', 'url': 'https://www.tramcar.org', 'site': 1, 'user': 1 } response = self.client.post( reverse('companies_edit', args=(self.company.id,)), company ) # Here we refresh the object otherwise it will show the old content # from before the update self.company.refresh_from_db() self.assertRedirects(response, self.company.get_absolute_url())
class CompanyUnauthdViewTests(TestCase): def setUp(self): user = User(username='******') user.set_password('password') user.full_clean() user.save() self.company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) self.company.full_clean() self.company.save() def test_index_view(self): response = self.client.get(reverse('companies_index')) self.assertEqual(response.status_code, 200) def test_new_view(self): response = self.client.get(reverse('companies_new')) self.assertRedirects(response, '/login/?next=/companies/new') def test_show_view(self): response = self.client.get(self.company.get_absolute_url()) self.assertEqual(response.status_code, 200) def test_show_view_without_slug_redirects_to_slug(self): response = self.client.get( reverse('companies_show', args=(self.company.id, ))) self.assertRedirects(response, self.company.get_absolute_url(), status_code=301) def test_show_view_does_not_display_edit_link(self): response = self.client.get(self.company.get_absolute_url()) url = reverse('companies_edit', args=(self.company.id, )) edit = '<a class="btn btn-primary btn-sm" ' \ 'href="%s">Edit Company</a>' % url self.assertNotContains(response, edit) def test_edit_view(self): response = self.client.get( reverse('companies_edit', args=(self.company.id, ))) url = reverse('companies_edit', args=(self.company.id, )) self.assertRedirects(response, '/login/?next=%s' % url)
class CompanyUnauthdViewTests(TestCase): def setUp(self): user = User(username='******') user.set_password('password') user.full_clean() user.save() self.company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) self.company.full_clean() self.company.save() def test_index_view(self): response = self.client.get(reverse('companies_index')) self.assertEqual(response.status_code, 200) def test_new_view(self): response = self.client.get(reverse('companies_new')) self.assertRedirects(response, '/login/?next=/companies/new') def test_show_view(self): response = self.client.get(self.company.get_absolute_url()) self.assertEqual(response.status_code, 200) def test_show_view_without_slug_redirects_to_slug(self): response = self.client.get( reverse('companies_show', args=(self.company.id,)) ) self.assertRedirects( response, self.company.get_absolute_url(), status_code=301 ) def test_show_view_does_not_display_edit_link(self): response = self.client.get(self.company.get_absolute_url()) url = reverse('companies_edit', args=(self.company.id,)) edit = '<a class="btn btn-primary btn-sm" ' \ 'href="%s">Edit Company</a>' % url self.assertNotContains(response, edit) def test_edit_view(self): response = self.client.get( reverse('companies_edit', args=(self.company.id,)) ) url = reverse('companies_edit', args=(self.company.id,)) self.assertRedirects(response, '/login/?next=%s' % url)
def setUp(self): user = User(username='******') user.set_password('password') user.full_clean() user.save() company = Company(name='Tramcar', url='http://www.tramcar.org', site_id=1, user_id=user.id) company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=user.id, city='Toronto', state='Ontario', email='*****@*****.**') job.paid_at = job.created_at job.full_clean() job.save()
def setUp(self): password = '******' admin = User(username='******') admin.is_staff = True admin.set_password(password) admin.full_clean() admin.save() self.other = User(username='******') self.other.set_password(password) self.other.full_clean() self.other.save() country = Country(name='Canada') country.full_clean() country.save() company = Company(name='Tramcar', site_id=1, user_id=self.other.id, url='http://www.tramcar.org') company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=self.other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job.full_clean() self.job.save() self.client.post( '/login/', {'username': admin.username, 'password': password} )
def setUp(self): password = '******' owner = User(username='******') owner.set_password(password) owner.full_clean() owner.save() other = User(username='******') other.set_password(password) other.full_clean() other.save() country = Country(name='Canada') country.full_clean() country.save() company = Company(name='Tramcar', site_id=1, user_id=owner.id, url='http://www.tramcar.org') company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job1 = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=owner.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job1.full_clean() self.job1.save() self.job1.activate() self.job2 = Job(title='QA Engineer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job2.full_clean() self.job2.save() self.job2.activate() self.job3 = Job(title='DevOps Engineer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job3.full_clean() self.job3.save() self.job4 = Job(title='Growth Hacker', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=owner.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job4.full_clean() self.job4.save() self.client.post('/login/', { 'username': owner.username, 'password': password })
def setUp(self): password = '******' owner = User(username='******') owner.set_password(password) owner.full_clean() owner.save() other = User(username='******') other.set_password(password) other.full_clean() other.save() country = Country(name='Canada') country.full_clean() country.save() company = Company(name='Tramcar', site_id=1, user_id=owner.id, url='http://www.tramcar.org') company.full_clean() company.save() category = Category(name='Software Development', site_id=1) category.full_clean() category.save() self.job1 = Job(title='Software Developer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=owner.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job1.full_clean() self.job1.save() self.job1.activate() self.job2 = Job(title='QA Engineer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job2.full_clean() self.job2.save() self.job2.activate() self.job3 = Job(title='DevOps Engineer', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=other.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job3.full_clean() self.job3.save() self.job4 = Job(title='Growth Hacker', description='Test description', application_info='test', category_id=category.id, company_id=company.id, site_id=1, user_id=owner.id, city='Toronto', state='Ontario', email='*****@*****.**') self.job4.full_clean() self.job4.save() self.client.post( '/login/', {'username': owner.username, 'password': password} )