Newer
Older
GestionHoteleriaApi / apps / user / tests.py
from apps.user.models import Gender
from apps.user.views import GenderViewSet
from django.test import TestCase

# Create your tests here.
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APIClient


class UserTest(TestCase):

    def setUp(self):
        self.client = APIClient()

        self.nodo_gender = Gender.objects.create(name='Masculino', acronym='M')

    # def test_can_update_gender(self):
    #     url = reverse(GenderViewSet.name, kwargs={'pk': self.nodo_gender.id})
    #
    #     data = {'name': 'Femenina'}
    #     resp = self.client.put(url, data, format='json')
    #     output = resp.data
    #     self.assertEqual(resp.status_code, status.HTTP_200_OK)
    #     self.assertEqual(output['id'], self.nodo_gender.id)
    #     self.assertEqual(output['name'], 'Femenina')


class ViewsUrlsTest(TestCase):

    def test_view_url_exists_at_desired_location_of_gender(self):
        resp = self.client.get('/user/gender/')
        self.assertEqual(resp.status_code, 200)

    def test_view_url_exists_at_desired_location_of_user(self):
        resp = self.client.get('/user/user/')
        self.assertEqual(resp.status_code, 200)

    def test_view_url_exists_at_desired_location_of_group(self):
        resp = self.client.get('/user/group/')
        self.assertEqual(resp.status_code, 200)

    def test_view_url_exists_at_desired_location_of_region(self):
        resp = self.client.get('/user/region/')
        self.assertEqual(resp.status_code, 200)

    def test_view_url_exists_at_desired_location_of_regiongovern(self):
        resp = self.client.get('/user/regiongovern/')
        self.assertEqual(resp.status_code, 200)