def detail_website_state_test(self, website):
        """
        Tests site detail component's presentation_agent initial state
        """
        control_agent = DetailSiteControlAgent(website)
        presentation_agent = control_agent.get_presentation_agent()
        done = website.done
        enabled = website.enabled
        refresh_gui()

        # Tests checkboxes state
        flags = {
            'enabled': enabled,
            'maintenance': website.maintenance
            }
        self.assert_widgets_active_flag(presentation_agent, flags)

        # Tests widgets sensitivity
        flags = {
            'enabled': not done,
            'maintenance': enabled,
            'template': not done and enabled,
            'access': enabled,
            }
        self.assert_widgets_sensitive_flag(presentation_agent, flags)
    def test_detail_website_abstraction_actions(self):
        """
        Tests that site detail component's abstractions changes are correctly
        reported to GUI.
        """
        site = SiteConfigurationManager.get_blank_site()
        website = site.website
        control_agent = DetailSiteControlAgent(website)
        presentation_agent = control_agent.get_presentation_agent()
        refresh_gui()

        # Enables component
        website.enabled = True
        refresh_gui()

        # Tests widgets sensitivity after enablement
        flags = {
            'enabled': True,
            'maintenance': True,
            'template': True,
            'access': True,
            }
        self.assert_widgets_sensitive_flag(presentation_agent, flags)

        # When a widget is enabled, the corresponding attribute should follow
        for name in ('enabled', 'maintenance'):
            setattr(website, name, True)
            refresh_gui()
            self.assert_widgets_active_flag(presentation_agent, {name: True})

        # Comboboxes value should reflect abstraction changes
        template = SiteDefaultsManager.get_site_templates().keys()[0]
        access = SiteDefaultsManager.get_site_accesses().keys()[0]

        for name, value in {'template': template, 'access': access}.items():
            setattr(website, name, value)
            refresh_gui()
            self.assertEquals(presentation_agent.get_combobox_selection(
                presentation_agent[name]), value,
                'site %s: %s/%s widget selection is wrong' % (name, value, presentation_agent.get_combobox_selection(presentation_agent[name])))

        # Tests that when done flag is set, sentivity is disabled on enabled
        # and template widgets. Maintenance and access should remain sensitive
        website.done = True
        refresh_gui()

        # Tests final widgets sensitivity
        flags = {
            'enabled': False,
            'template': False,
            'maintenance': True,
            'access': True,
            }
        self.assert_widgets_sensitive_flag(presentation_agent, flags)
    def test_detail_website_read_only(self):
        """
        Tests that site detail component's abstractions changes are correctly
        reported to GUI.
        """
        site = SiteConfigurationManager.get_blank_site()
        website = site.website
        control_agent = DetailSiteControlAgent(website, read_only=True)
        presentation_agent = control_agent.get_presentation_agent()
        refresh_gui()

        # Ine read-only mode, all widgets should be disabled
        flags = {
            'enabled': False,
            'maintenance': False,
            'template': False,
            'access': False
            }
        self.assert_widgets_sensitive_flag(presentation_agent, flags)
    def test_detail_website_gui_actions(self):
        """
        Tests that site detail component's presentation_agent works as
        expected, and that abstraction attributes are set correspondingly to
        GUI actions.
        """
        site = SiteConfigurationManager.get_blank_site()
        website = site.website
        control_agent = DetailSiteControlAgent(website)
        presentation_agent = control_agent.get_presentation_agent()
        refresh_gui()

        # Enables component
        presentation_agent['enabled'].set_active(True)
        refresh_gui()

        # Tests widgets sensitivity after enablement
        flags = {
            'enabled': True,
            'maintenance': True,
            'template': True,
            'access': True,
            }
        self.assert_widgets_sensitive_flag(presentation_agent, flags)

        # When a checkbox is enabled, the corresponding attribute should follow
        for name in ('enabled', 'maintenance'):
            presentation_agent[name].set_active(True)
            refresh_gui()
            self.assertTrue(getattr(website, name),
                            'site %s attribute is not enabled' % name)

        # Comboboxes value should be reported to abstraction
        template = SiteDefaultsManager.get_site_templates().keys()[0]
        access = SiteDefaultsManager.get_site_accesses().keys()[0]

        for name, value in {'template': template, 'access': access}.items():
            presentation_agent.set_value(name, value)
            refresh_gui()
            self.assertEquals(getattr(website, name), value,
                             'site %s attribute is wrong' % name)