Exemplo n.º 1
0
 def _do_fake_registration(self):
     # Create a Zone and DeviceZone to fool the Device into thinking it's registered
     zone = Zone(name="The Danger Zone", description="Welcome to it.")
     zone.save()
     device = Device.get_own_device()
     deviceZone = DeviceZone(device=device, zone=zone)
     deviceZone.save()
Exemplo n.º 2
0
 def _do_fake_registration(self):
     # Create a Zone and DeviceZone to fool the Device into thinking it's registered
     zone = Zone(name="The Danger Zone", description="Welcome to it.")
     zone.save()
     device = Device.get_own_device()
     deviceZone = DeviceZone(device=device, zone=zone)
     deviceZone.save()
Exemplo n.º 3
0
class ZoneDeletionTestCase(OrganizationManagementTestCase):
    def setUp(self):
        super(ZoneDeletionTestCase, self).setUp()
        self.zone = Zone(name=self.ZONE_NAME)
        self.zone.save()
        self.org.add_zone(self.zone)
        self.org.save()

    def test_delete_zone_from_org_admin(self):
        """Delete a zone from the org_management page"""
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        self.browser.find_element_by_css_selector(".zone-delete-link").click()
        self.browser.switch_to_alert().accept()
        self.browser_wait_for_no_element(".zone-delete-link")
        self.browser_check_django_message(message_type="success",
                                          contains="successfully deleted")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(
                self.browser.find_element_by_css_selector(".zone-delete-link"),
                None, "Make sure 'delete' link is gone.")

    def test_cancel_delete_zone_from_org_admin(self):
        """Delete a zone from the org_management page"""
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        self.browser.find_element_by_css_selector(".zone-delete-link").click()
        self.browser.switch_to_alert().dismiss()
        self.assertNotEqual(
            self.browser.find_element_by_css_selector(".zone-delete-link"),
            None, "Make sure 'delete' link still exists.")
        self.browser_check_django_message(num_messages=0)

    def test_cannot_delete_full_zone(self):
        # Save zone info, but without adding
        self.devicezone = DeviceZone(device=Device.get_own_device(),
                                     zone=self.zone)
        self.devicezone.save()

        # Check on the org management page
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(
                self.browser.find_element_by_css_selector(".zone-delete-link"),
                None, "Make sure 'delete' link is gone.")

        # Follow the link, and confirm on the zone management page.
        zone_url = self.browser.find_element_by_css_selector(
            ".zone-manage-link").get_attribute("href")
        self.browse_to(zone_url)
        self.assertEqual(self.browser.current_url, zone_url,
                         "Expect link to go to zone management page")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(
                self.browser.find_element_by_css_selector(".zone-delete-link"),
                None, "Make sure 'delete' link is gone.")

    def test_issue_697_part1(self):
        self.facility = Facility(name=self.FACILITY_NAME)
        self.facility.save()
        self.test_delete_zone_from_org_admin()
Exemplo n.º 4
0
def do_fake_registration():
    """
    Register the device, in case some feature being tested depends on it. Will be undone by the database teardown.
    """
    # Create a Zone and DeviceZone to fool the Device into thinking it's registered
    zone = Zone(name="The Danger Zone", description="Welcome to it.")
    zone.save()
    device = Device.get_own_device()
    device_zone = DeviceZone(device=device, zone=zone)
    device_zone.save()
Exemplo n.º 5
0
def do_fake_registration():
    """
    Register the device, in case some feature being tested depends on it. Will be undone by the database teardown.
    """
    # Create a Zone and DeviceZone to fool the Device into thinking it's registered
    zone = Zone(name="The Danger Zone", description="Welcome to it.")
    zone.save()
    device = Device.get_own_device()
    device_zone = DeviceZone(device=device, zone=zone)
    device_zone.save()
Exemplo n.º 6
0
class ZoneDeletionTestCase(OrganizationManagementTestCase):
    def setUp(self):
        super(ZoneDeletionTestCase, self).setUp()
        self.zone = Zone(name=self.ZONE_NAME)
        self.zone.save()
        self.org.add_zone(self.zone)
        self.org.save()


    def test_delete_zone_from_org_admin(self):
        """Delete a zone from the org_management page"""
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        self.browser.find_element_by_css_selector(".zone-delete-link").click()
        self.browser.switch_to_alert().accept()
        self.browser_wait_for_no_element(".zone-delete-link")
        self.browser_check_django_message(message_type="success", contains="successfully deleted")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")

    def test_cancel_delete_zone_from_org_admin(self):
        """Delete a zone from the org_management page"""
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        self.browser.find_element_by_css_selector(".zone-delete-link").click()
        self.browser.switch_to_alert().dismiss()
        self.assertNotEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link still exists.")
        self.browser_check_django_message(num_messages=0)


    def test_cannot_delete_full_zone(self):
        # Save zone info, but without adding
        self.devicezone = DeviceZone(device=Device.get_own_device(), zone=self.zone)
        self.devicezone.save()

        # Check on the org management page
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")

        # Follow the link, and confirm on the zone management page.
        zone_url = self.browser.find_element_by_css_selector(".zone-manage-link").get_attribute("href")
        self.browse_to(zone_url)
        self.assertEqual(self.browser.current_url, zone_url, "Expect link to go to zone management page")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")

    def test_issue_697_part1(self):
        self.facility = Facility(name=self.FACILITY_NAME)
        self.facility.save()
        self.test_delete_zone_from_org_admin()
Exemplo n.º 7
0
    def test_cannot_delete_full_zone(self):
        # Save zone info, but without adding
        self.devicezone = DeviceZone(device=Device.get_own_device(), zone=self.zone)
        self.devicezone.save()

        # Check on the org management page
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")

        # Follow the link, and confirm on the zone management page.
        zone_url = self.browser.find_element_by_css_selector(".zone-manage-link").get_attribute("href")
        self.browse_to(zone_url)
        self.assertEqual(self.browser.current_url, zone_url, "Expect link to go to zone management page")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")
    def test_cannot_delete_full_zone(self):
        # Save zone info, but without adding
        self.devicezone = DeviceZone(device=Device.get_own_device(), zone=self.zone)
        self.devicezone.save()

        # Check on the org management page
        self.browser_login_user(self.USER_EMAIL, self.USER_PASSWORD)
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")

        # Follow the link, and confirm on the zone management page.
        zone_url = self.browser.find_element_by_css_selector(".zone-manage-link").get_attribute("href")
        self.browse_to(zone_url)
        self.assertEqual(self.browser.current_url, zone_url, "Expect link to go to zone management page")
        with self.assertRaises(NoSuchElementException):
            self.assertEqual(self.browser.find_element_by_css_selector(".zone-delete-link"), None, "Make sure 'delete' link is gone.")