def test_get_exact_no_match(self): mommy.make( 'djthirdparty.CustomContent', javascript='text1', path='/other1/') mommy.make( 'djthirdparty.CustomContent', javascript='text2', path='/other2/') self.assertEqual( custom_content(self.request)['custom_javascript_footer'], '')
def test_get_partial_no_match(self): request = RequestFactory().get('/other/') mommy.make( 'djthirdparty.CustomContent', javascript='text1', path='^/misc/') self.assertEqual( custom_content(request)['custom_javascript_footer'], '')
def test_get_exact(self): mommy.make('djthirdparty.CustomContent', javascript='text1', path='/') mommy.make('djthirdparty.CustomContent', javascript='text2', path='/other/') self.assertEqual( custom_content(self.request)['custom_javascript_footer'], 'text1')
def test_request_custom_content_not_active(self): js = "alert('hello world');" mommy.make( 'djthirdparty.CustomContent', active=False, javascript=js, path="/") self.assertEqual( custom_content(self.request)['custom_javascript_footer'], '')
def test_get_partial_partial_match_header(self): request = RequestFactory().get('/other/misc/') mommy.make( 'djthirdparty.CustomContent', javascript='text1', path='^/other/', exact_match=False, partial_match=True, header=True) self.assertEqual( custom_content(request)['custom_javascript_header'], 'text1')
def test_get_partial_no_match(self): request = RequestFactory().get('/other/') mommy.make('djthirdparty.CustomContent', javascript='text1', path='^/misc/') self.assertEqual( custom_content(request)['custom_javascript_footer'], '')
def test_get_exact_no_match_header(self): mommy.make( 'djthirdparty.CustomContent', javascript='text1', path='/other/', header=True) mommy.make( 'djthirdparty.CustomContent', javascript='text2', path='/misc/', header=True) self.assertEqual( custom_content(self.request)['custom_javascript_header'], '')
def test_request_custom_content_not_active(self): js = "alert('hello world');" mommy.make('djthirdparty.CustomContent', active=False, javascript=js, path="/") self.assertEqual( custom_content(self.request)['custom_javascript_footer'], '')
def test_get_partial_partial_match_header(self): request = RequestFactory().get('/other/misc/') mommy.make('djthirdparty.CustomContent', javascript='text1', path='^/other/', exact_match=False, partial_match=True, header=True) self.assertEqual( custom_content(request)['custom_javascript_header'], 'text1')
def test_get_exact_no_match_header(self): mommy.make('djthirdparty.CustomContent', javascript='text1', path='/other/', header=True) mommy.make('djthirdparty.CustomContent', javascript='text2', path='/misc/', header=True) self.assertEqual( custom_content(self.request)['custom_javascript_header'], '')
def test_request_no_data(self): self.assertEqual( custom_content(self.request)['custom_javascript_footer'], '')
def test_no_request(self): self.assertEqual(custom_content(None), {})