def test_cursor_valid_2_items(self): cursor = is_cursor("url(some.url), url(some.url2)") self.assertEqual(str(cursor), 'url("some.url"), url("some.url2")') cursor = is_cursor("url(some.url), auto") self.assertEqual(str(cursor), 'url("some.url"), auto') cursor = is_cursor(["url(some.url)", "url(some.url2)"]) self.assertEqual(str(cursor), 'url("some.url"), url("some.url2")') cursor = is_cursor(["url(some.url)", "auto"]) self.assertEqual(str(cursor), 'url("some.url"), auto')
def test_cursor_invalid_2_items(self): with self.assertRaises(ValidationError): is_cursor("foobar, blah") with self.assertRaises(ValidationError): is_cursor("auto, url( something )") with self.assertRaises(ValidationError): is_cursor(["foobar", 'blah']) with self.assertRaises(ValidationError): is_cursor(["auto", "url(something)"]) with self.assertRaises(ValidationError): is_cursor(["url(something)", "auto", "url(something)"])
def test_cursor_valid_1_item(self): cursor = is_cursor("url(some.url)") self.assertEqual(str(cursor), 'url("some.url")') cursor = is_cursor(" url(some.url) ") self.assertEqual(str(cursor), 'url("some.url")') cursor = is_cursor("url('some.url')") self.assertEqual(str(cursor), 'url("some.url")') cursor = is_cursor("url( 'some.url' )") self.assertEqual(str(cursor), 'url("some.url")') cursor = is_cursor('url("some.url")') self.assertEqual(str(cursor), 'url("some.url")') cursor = is_cursor('url( "some.url" )') self.assertEqual(str(cursor), 'url("some.url")')
def test_cursor_invalid_1_item(self): with self.assertRaises(ValidationError): is_cursor("foobar") with self.assertRaises(ValidationError): is_cursor(["foobar"])