import pytest
from rest_framework import status
from rest_framework.reverse import reverse


@pytest.mark.unit
@pytest.mark.django_db
class TestProductAPI:

    @pytest.fixture(autouse=True)
    def setup_tests(self, django_user_model):
        self.admin_user = django_user_model.objects.get(username='admin')

    def test_get_product_version(self, api_client):
        api_client.force_authenticate(self.admin_user)
        response = api_client.get(reverse('api_product_version'))
        assert response.status_code == status.HTTP_200_OK
        assert response.data['product'] == 'InfoWatch ARMA Management Console'
        assert response.data['version'] == ' 555'


@pytest.mark.unit
@pytest.mark.django_db
class TestConsoleAPI:

    def test_check_invalid_path(self, api_client):
        response = api_client.get('/en/api/product/version/')
        assert response.status_code == status.HTTP_403_FORBIDDEN  # it is normal behavior, path exists

        response = api_client.get('/en/api/invalid/')
        assert response.status_code == status.HTTP_404_NOT_FOUND

        response = api_client.get('/en/api/device/')
        assert response.status_code == status.HTTP_404_NOT_FOUND
