|
| 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() |
0 commit comments