Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SensoriViewTest(TestCase):
- fixtures = ['app']
- def test_sensori_url_exist_at_desidered_location(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get('/sensori/')
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_sensori_url_accessibile_by_name(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get(reverse('sensori'))
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_sensori_redirect_if_not_logged_in(self):
- resp = self.client.get(reverse('sensori'))
- self.assertRedirects(resp, expected_url='/login/?next=/sensori/', status_code=302, target_status_code=200)
- # def test_sensori_list_correct(self):
- # self.client.login(username='admin', password='12345')
- # resp = self.client.get(reverse('sensori'))
- # print(resp.context['sensori'])
- # self.assertContains(resp.context['sensori'], )
- class EliminaSensoreTest(TestCase):
- fixtures = ['app']
- def test_elimina_sensore_url_exist_at_desired_location(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get('/sensori/elimina/', {'id': 'hrwfiu33'})
- self.assertRedirects(resp, expected_url=reverse('sensori'), status_code=302, target_status_code=200)
- def test_elimina_sensore_url_accesibile_by_name(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get(reverse('elimina_sensore'), {'id': 'hrwfiu33'})
- self.assertRedirects(resp, expected_url=reverse('sensori'), status_code=302, target_status_code=200)
- def test_elimina_sensore_no_id_get_param(self):
- self.client.login(username='admin', password='12345')
- with self.assertRaises(MultiValueDictKeyError):
- self.client.get(reverse('elimina_sensore'))
- def test_elimina_sensore_has_been_deleted(self):
- self.client.login(username='admin', password='12345')
- id_sensore_scelto = 'hrwfiu33'
- self.client.get(reverse('elimina_sensore'), {'id': 'hrwfiu33'})
- sensore_da_eliminare = Sensore.objects.get(id=id_sensore_scelto)
- impianto_sensore = sensore_da_eliminare.get_impianto()
- installazione = sensore_da_eliminare.get_last_installazione()
- self.assertNotIn(sensore_da_eliminare, impianto_sensore.get_sensori())
- self.assertIsNotNone(installazione.data_fine)
- class RilevazioniViewTest(TestCase):
- fixtures = ['app']
- def test_rilevazioni_url_exist_at_desidered_location(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get('/rilevazioni/', {
- 'id_sensore': "hrwfiu33"
- })
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_rilevazioni_url_accessibile_by_name(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get(reverse('rilevazioni'), {
- 'id_sensore': "hrwfiu33"
- })
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_rilevazioni_redirect_if_not_logged_in(self):
- resp = self.client.get(reverse('rilevazioni'))
- self.assertRedirects(resp, expected_url='/login/?next=/rilevazioni/', status_code=302, target_status_code=200)
- #def test_rilevazioni_no_sensore_id_get_param(self):
- # self.client.login(username='admin', password='12345')
- # with self.assertRaises(MultiValueDictKeyError):
- # self.client.get(reverse('rilevazioni'))
- class UtentiViewTest(TestCase):
- fixtures = ['app']
- def test_utenti_url_exist_at_desidered_location(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get('/utenti/')
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_utenti_url_accessibile_by_name(self):
- self.client.login(username='admin', password='12345')
- resp = self.client.get(reverse('utenti'))
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- def test_utenti_redirect_if_not_logged_in(self):
- resp = self.client.get(reverse('utenti'))
- self.assertRedirects(resp, expected_url='/login/?next=/utenti/', status_code=302, target_status_code=200)
- class EliminaUtenteViewTest(TestCase):
- fixtures = ['app']
- def test_elimina_sensore_no_id_get_param(self):
- self.client.login(username='admin', password='12345')
- with self.assertRaises(MultiValueDictKeyError):
- self.client.get(reverse('elimina_utente'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement