def test_display_advertising(self): with override_settings(GOOGLE_ANALYTICS_DISPLAY_ADVERTISING=False): r = GoogleAnalyticsNode().render(Context()) self.assertTrue("google-analytics.com/ga.js" in r, r) with override_settings(GOOGLE_ANALYTICS_DISPLAY_ADVERTISING=True): r = GoogleAnalyticsNode().render(Context()) self.assertTrue("stats.g.doubleclick.net/dc.js" in r, r)
def test_button_effect(self): r = SnapEngageNode().render(Context({ 'snapengage_button_effect': "-4px"})) self.assertTrue('SnapABug.setButtonEffect("-4px");' in r, r) with override_settings(SNAPENGAGE_BUTTON_EFFECT="-4px"): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setButtonEffect("-4px");' in r, r)
def test_form_position(self): r = SnapEngageNode().render(Context({ 'snapengage_form_position': FORM_POSITION_TOP_LEFT})) self.assertTrue('SnapABug.setChatFormPosition("tl");' in r, r) with override_settings(SNAPENGAGE_FORM_POSITION=FORM_POSITION_TOP_LEFT): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setChatFormPosition("tl");' in r, r)
def test_form_top_position(self): r = SnapEngageNode().render(Context({ 'snapengage_form_top_position': 40})) self.assertTrue('SnapABug.setFormTopPosition(40);' in r, r) with override_settings(SNAPENGAGE_FORM_TOP_POSITION=40): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setFormTopPosition(40);' in r, r)
def test_offline_screenshots(self): r = SnapEngageNode().render( Context({'snapengage_offline_screenshots': False})) self.assertTrue('SnapABug.showScreenshotOption(false);' in r, r) with override_settings(SNAPENGAGE_OFFLINE_SCREENSHOTS=False): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.showScreenshotOption(false);' in r, r)
def test_show_offline(self): r = SnapEngageNode().render(Context({'snapengage_show_offline': False})) self.assertTrue('SnapABug.allowOffline(false);' in r, r) with override_settings(SNAPENGAGE_SHOW_OFFLINE=False): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.allowOffline(false);' in r, r)
def test_secure_connection(self): r = SnapEngageNode().render( Context({'snapengage_secure_connection': True})) self.assertTrue('SnapABug.setSecureConnexion();' in r, r) with override_settings(SNAPENGAGE_SECURE_CONNECTION=True): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setSecureConnexion();' in r, r)
def test_domain(self): r = SnapEngageNode().render( Context({'snapengage_domain': "example.com"})) self.assertTrue('SnapABug.setDomain("example.com");' in r, r) with override_settings(SNAPENGAGE_DOMAIN="example.com"): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setDomain("example.com");' in r, r)
def test_form_top_position(self): r = SnapEngageNode().render( Context({'snapengage_form_top_position': 40})) self.assertTrue('SnapABug.setFormTopPosition(40);' in r, r) with override_settings(SNAPENGAGE_FORM_TOP_POSITION=40): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setFormTopPosition(40);' in r, r)
def test_button_effect(self): r = SnapEngageNode().render( Context({'snapengage_button_effect': "-4px"})) self.assertTrue('SnapABug.setButtonEffect("-4px");' in r, r) with override_settings(SNAPENGAGE_BUTTON_EFFECT="-4px"): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setButtonEffect("-4px");' in r, r)
def test_domain(self): r = SnapEngageNode().render(Context({ 'snapengage_domain': "example.com"})) self.assertTrue('SnapABug.setDomain("example.com");' in r, r) with override_settings(SNAPENGAGE_DOMAIN="example.com"): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setDomain("example.com");' in r, r)
def test_secure_connection(self): r = SnapEngageNode().render(Context({ 'snapengage_secure_connection': True})) self.assertTrue('SnapABug.setSecureConnexion();' in r, r) with override_settings(SNAPENGAGE_SECURE_CONNECTION=True): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setSecureConnexion();' in r, r)
def test_offline_screenshots(self): r = SnapEngageNode().render(Context( {'snapengage_offline_screenshots': False})) self.assertTrue('SnapABug.showScreenshotOption(false);' in r, r) with override_settings(SNAPENGAGE_OFFLINE_SCREENSHOTS=False): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.showScreenshotOption(false);' in r, r)
def test_form_position(self): r = SnapEngageNode().render( Context({'snapengage_form_position': FORM_POSITION_TOP_LEFT})) self.assertTrue('SnapABug.setChatFormPosition("tl");' in r, r) with override_settings( SNAPENGAGE_FORM_POSITION=FORM_POSITION_TOP_LEFT): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setChatFormPosition("tl");' in r, r)
def test_rendering_setup_site(self): site = Site.objects.create(domain="test.com", name="test") with override_settings(SITE_ID=site.id): r = ChartbeatBottomNode().render(Context()) self.assertTrue(re.search( 'var _sf_async_config={.*"uid": "12345".*};', r), r) self.assertTrue(re.search( 'var _sf_async_config={.*"domain": "test.com".*};', r), r)
def test_no_button(self): r = SnapEngageNode().render(Context({'snapengage_button': BUTTON_STYLE_NONE})) self.assertTrue('SnapABug.init("ec329c69-0bf0-4db8-9b77-3f8150fb977e")' in r, r) with override_settings(SNAPENGAGE_BUTTON=BUTTON_STYLE_NONE): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.init("ec329c69-0bf0-4db8-9b77-3f8150fb977e")' in r, r)
def test_rendering_setup_site(self): site = Site.objects.create(domain="test.com", name="test") with override_settings(SITE_ID=site.id): r = ChartbeatBottomNode().render(Context()) self.assertTrue( re.search('var _sf_async_config={.*"uid": "12345".*};', r), r) self.assertTrue( re.search('var _sf_async_config={.*"domain": "test.com".*};', r), r)
def test_only_disable_within_context_manager(self): """ Make sure deleted settings returns once the block exits. """ self.assertEqual(settings.USER_ID, 1) with override_settings(USER_ID=SETTING_DELETED): self.assertRaises(AttributeError, getattr, settings, "USER_ID") self.assertEqual(settings.USER_ID, 1)
def test_email_readonly(self): r = SnapEngageNode().render(Context({'snapengage_email': '*****@*****.**', 'snapengage_readonly_email': True})) self.assertTrue('SnapABug.setUserEmail("*****@*****.**",true);' in r, r) with override_settings(SNAPENGAGE_READONLY_EMAIL=True): r = SnapEngageNode().render(Context({'snapengage_email': '*****@*****.**'})) self.assertTrue('SnapABug.setUserEmail("*****@*****.**",true);' in r, r)
def test_no_button(self): r = SnapEngageNode().render( Context({'snapengage_button': BUTTON_STYLE_NONE})) self.assertTrue( 'SnapABug.init("ec329c69-0bf0-4db8-9b77-3f8150fb977e")' in r, r) with override_settings(SNAPENGAGE_BUTTON=BUTTON_STYLE_NONE): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.init("ec329c69-0bf0-4db8-9b77-3f8150fb977e")' in r, r)
def test_live_button(self): r = SnapEngageNode().render(Context({'snapengage_button': BUTTON_STYLE_LIVE})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%",true);' in r, r) with override_settings(SNAPENGAGE_BUTTON=BUTTON_STYLE_LIVE): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%",true);' in r, r)
def test_button_location_top(self): r = SnapEngageNode().render( Context({'snapengage_button_location': BUTTON_LOCATION_TOP})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","2",' '"55%");' in r, r) with override_settings(SNAPENGAGE_BUTTON_LOCATION=BUTTON_LOCATION_TOP): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","2",' '"55%");' in r, r)
def test_button_offset(self): r = SnapEngageNode().render( Context({'snapengage_button_location_offset': "30%"})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"30%");' in r, r) with override_settings(SNAPENGAGE_BUTTON_LOCATION_OFFSET="30%"): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"30%");' in r, r)
def test_live_button(self): r = SnapEngageNode().render( Context({'snapengage_button': BUTTON_STYLE_LIVE})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%",true);' in r, r) with override_settings(SNAPENGAGE_BUTTON=BUTTON_STYLE_LIVE): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%",true);' in r, r)
def test_button_location_top(self): r = SnapEngageNode().render(Context({ 'snapengage_button_location': BUTTON_LOCATION_TOP})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","2",' '"55%");' in r, r) with override_settings(SNAPENGAGE_BUTTON_LOCATION=BUTTON_LOCATION_TOP): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","2",' '"55%");' in r, r)
def test_button_offset(self): r = SnapEngageNode().render(Context({ 'snapengage_button_location_offset': "30%"})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"30%");' in r, r) with override_settings(SNAPENGAGE_BUTTON_LOCATION_OFFSET="30%"): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"30%");' in r, r)
def test_email_readonly(self): r = SnapEngageNode().render( Context({ 'snapengage_email': '*****@*****.**', 'snapengage_readonly_email': True })) self.assertTrue('SnapABug.setUserEmail("*****@*****.**",true);' in r, r) with override_settings(SNAPENGAGE_READONLY_EMAIL=True): r = SnapEngageNode().render( Context({'snapengage_email': '*****@*****.**'})) self.assertTrue( 'SnapABug.setUserEmail("*****@*****.**",true);' in r, r)
def test_custom_button(self): r = SnapEngageNode().render(Context({ 'snapengage_button': "http://www.example.com/button.png"})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%");' in r, r) self.assertTrue( 'SnapABug.setButton("http://www.example.com/button.png");' in r, r) with override_settings( SNAPENGAGE_BUTTON="http://www.example.com/button.png"): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%");' in r, r) self.assertTrue( 'SnapABug.setButton("http://www.example.com/button.png");' in r, r)
def test_custom_button(self): r = SnapEngageNode().render( Context({'snapengage_button': "http://www.example.com/button.png"})) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%");' in r, r) self.assertTrue( 'SnapABug.setButton("http://www.example.com/button.png");' in r, r) with override_settings( SNAPENGAGE_BUTTON="http://www.example.com/button.png"): r = SnapEngageNode().render(Context()) self.assertTrue( 'SnapABug.addButton("ec329c69-0bf0-4db8-9b77-3f8150fb977e","0",' '"55%");' in r, r) self.assertTrue( 'SnapABug.setButton("http://www.example.com/button.png");' in r, r)
def test_get_domain_from_site(self): site = Site.objects.create(domain="example.com", name="test") with override_settings(SITE_ID=site.id): context = Context() self.assertEqual(get_domain(context, 'test'), 'example.com')
def test_sounds(self): r = SnapEngageNode().render(Context({'snapengage_sounds': False})) self.assertTrue('SnapABug.allowChatSound(false);' in r, r) with override_settings(SNAPENGAGE_SOUNDS=False): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.allowChatSound(false);' in r, r)
def test_language(self): r = SnapEngageNode().render(Context({'snapengage_locale': 'fr'})) self.assertTrue('SnapABug.setLocale("fr");' in r, r) with override_settings(SNAPENGAGE_LOCALE='fr'): r = SnapEngageNode().render(Context()) self.assertTrue('SnapABug.setLocale("fr");' in r, r)