Skip to content

Commit a42c4fc

Browse files
authored
[tests] Import django_loci selenium tests, fix failing readonly tests
1 parent ccf380c commit a42c4fc

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from django.contrib.auth import get_user_model
2+
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
3+
from django_loci.tests.base.test_selenium import BaseTestDeviceAdminSelenium
4+
from selenium.webdriver.common.by import By
5+
from swapper import load_model
6+
7+
from openwisp_users.tests.utils import TestOrganizationMixin
8+
9+
Device = load_model('config', 'Device')
10+
Location = load_model('geo', 'Location')
11+
FloorPlan = load_model('geo', 'FloorPlan')
12+
DeviceLocation = load_model('geo', 'DeviceLocation')
13+
14+
15+
class TestDeviceAdminSelenium(
16+
BaseTestDeviceAdminSelenium, TestOrganizationMixin, StaticLiveServerTestCase
17+
):
18+
app_label = 'geo'
19+
object_model = Device
20+
location_model = Location
21+
object_location_model = DeviceLocation
22+
user_model = get_user_model()
23+
24+
inline_field_prefix = 'devicelocation'
25+
26+
@classmethod
27+
def _get_prefix(cls):
28+
return cls.inline_field_prefix
29+
30+
def _fill_device_form(self):
31+
org = self._get_org()
32+
self.find_element(by=By.NAME, value='mac_address').send_keys(
33+
'11:22:33:44:55:66'
34+
)
35+
self.find_element(
36+
by=By.CSS_SELECTOR, value='#select2-id_organization-container'
37+
).click()
38+
self.wait_for_invisibility(
39+
By.CSS_SELECTOR, '.select2-results__option.loading-results'
40+
)
41+
self.find_element(by=By.CLASS_NAME, value='select2-search__field').send_keys(
42+
org.name
43+
)
44+
self.wait_for_invisibility(
45+
By.CSS_SELECTOR, '.select2-results__option.loading-results'
46+
)
47+
self.find_element(by=By.CLASS_NAME, value='select2-results__option').click()
48+
super()._fill_device_form()

openwisp_controller/geo/tests/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from swapper import load_model
44

55
Organization = load_model('openwisp_users', 'Organization')
6+
OrganizationUser = load_model('openwisp_users', 'OrganizationUser')
67

78

89
class TestGeoMixin(TestLociMixin):
@@ -56,3 +57,9 @@ def _create_object_location(self, **kwargs):
5657
ol.full_clean()
5758
ol.save()
5859
return ol
60+
61+
def _create_readonly_admin(self, **kwargs):
62+
user = super()._create_readonly_admin(**kwargs)
63+
org1 = self._create_organization()
64+
OrganizationUser.objects.create(user=user, organization=org1, is_admin=True)
65+
return user

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ django-reversion~=5.1.0
33
django-taggit~=6.0.0
44
netjsonconfig @ https://github.com/openwisp/netjsonconfig/tarball/1.2
55
django-x509 @ https://github.com/openwisp/django-x509/tarball/1.3
6-
django-loci @ https://github.com/openwisp/django-loci/tarball/1.2
6+
# temp for passing tests
7+
django-loci @ https://github.com/DragnEmperor/django-loci/tarball/1.2
78
django-flat-json-widget~=0.3.1
89
openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/1.2
910
openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/tarball/1.2

0 commit comments

Comments
 (0)