|
1 | 1 | import json
|
2 | 2 |
|
3 |
| -from django.test import override_settings |
| 3 | +from django.test import override_settings, tag |
4 | 4 | from django.urls import reverse
|
5 | 5 | from django.utils.translation import gettext as _
|
6 | 6 | from rest_framework import status
|
@@ -1904,6 +1904,27 @@ def setUpTestData(cls):
|
1904 | 1904 | },
|
1905 | 1905 | ]
|
1906 | 1906 |
|
| 1907 | + @tag('regression') # Issue #18991 |
| 1908 | + def test_front_port_paths(self): |
| 1909 | + device = Device.objects.first() |
| 1910 | + rear_port = RearPort.objects.create( |
| 1911 | + device=device, name='Rear Port 10', type=PortTypeChoices.TYPE_8P8C |
| 1912 | + ) |
| 1913 | + interface1 = Interface.objects.create(device=device, name='Interface 1') |
| 1914 | + front_port = FrontPort.objects.create( |
| 1915 | + device=device, |
| 1916 | + name='Rear Port 10', |
| 1917 | + type=PortTypeChoices.TYPE_8P8C, |
| 1918 | + rear_port=rear_port, |
| 1919 | + ) |
| 1920 | + Cable.objects.create(a_terminations=[interface1], b_terminations=[front_port]) |
| 1921 | + |
| 1922 | + self.add_permissions(f'dcim.view_{self.model._meta.model_name}') |
| 1923 | + url = reverse(f'dcim-api:{self.model._meta.model_name}-paths', kwargs={'pk': front_port.pk}) |
| 1924 | + response = self.client.get(url, **self.header) |
| 1925 | + |
| 1926 | + self.assertHttpStatus(response, status.HTTP_200_OK) |
| 1927 | + |
1907 | 1928 |
|
1908 | 1929 | class RearPortTest(APIViewTestCases.APIViewTestCase):
|
1909 | 1930 | model = RearPort
|
@@ -1947,6 +1968,23 @@ def setUpTestData(cls):
|
1947 | 1968 | },
|
1948 | 1969 | ]
|
1949 | 1970 |
|
| 1971 | + @tag('regression') # Issue #18991 |
| 1972 | + def test_rear_port_paths(self): |
| 1973 | + device = Device.objects.first() |
| 1974 | + interface1 = Interface.objects.create(device=device, name='Interface 1') |
| 1975 | + rear_port = RearPort.objects.create( |
| 1976 | + device=device, |
| 1977 | + name='Rear Port 10', |
| 1978 | + type=PortTypeChoices.TYPE_8P8C, |
| 1979 | + ) |
| 1980 | + Cable.objects.create(a_terminations=[interface1], b_terminations=[rear_port]) |
| 1981 | + |
| 1982 | + self.add_permissions(f'dcim.view_{self.model._meta.model_name}') |
| 1983 | + url = reverse(f'dcim-api:{self.model._meta.model_name}-paths', kwargs={'pk': rear_port.pk}) |
| 1984 | + response = self.client.get(url, **self.header) |
| 1985 | + |
| 1986 | + self.assertHttpStatus(response, status.HTTP_200_OK) |
| 1987 | + |
1950 | 1988 |
|
1951 | 1989 | class ModuleBayTest(APIViewTestCases.APIViewTestCase):
|
1952 | 1990 | model = ModuleBay
|
|
0 commit comments