Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The complete comment system revamp #424

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7f4740d
Merge with parent
dwitterer Oct 25, 2018
cc62f5a
Update hashtag regex
dwitterer Oct 25, 2018
a80595a
Summon the anchor annihilator
dwitterer Oct 26, 2018
8b25900
Remove a newline
dwitterer Oct 26, 2018
41612c4
Update README.md
dwitterer Oct 26, 2018
9e5226e
Fix unbalanced parenthesis
dwitterer Oct 26, 2018
f99d1db
Insert code blocks last, so the anchor annihilator can do its job
dwitterer Oct 26, 2018
ce1be01
Merge with parent
dwitterer Oct 26, 2018
a2ca8fa
Move long comments onto new lines
dwitterer Oct 26, 2018
c2a9df1
Fix other lint-python errors
dwitterer Oct 26, 2018
c6936b2
Fix other lint-python errors
dwitterer Oct 26, 2018
c3cf099
Final lint-python fixes
dwitterer Oct 26, 2018
6bbebe5
Final lint-python fixes
dwitterer Oct 26, 2018
a9a0864
Remove 2-character minimum for hashtags
dwitterer Oct 26, 2018
2eea517
Allow hashtags beginning with numbers
dwitterer Oct 26, 2018
3284320
Merge with parent
dwitterer Nov 9, 2018
cc5be1b
Automatically shorten magic links in dwitter.net/*/* form into proper…
dwitterer Nov 17, 2018
8b8a251
Spring cleaned this file up a bit
dwitterer Nov 17, 2018
6aa0770
Spring clean here also
dwitterer Nov 17, 2018
a689fd3
Clean up test_dweet
dwitterer Nov 17, 2018
a171111
Clean up test_comment
dwitterer Nov 17, 2018
5bdc35b
Update test_user_feeds.py
dwitterer Nov 17, 2018
dedaa2c
Cleaned this up
dwitterer Nov 17, 2018
db8b495
Update test_feed_views.py
dwitterer Nov 17, 2018
bf769d1
Update test_hashtag_feed_views.py
dwitterer Nov 17, 2018
95e50ab
Update test_hashtags.py
dwitterer Nov 17, 2018
e6b5431
Update test_insert_code_blocks.py
dwitterer Nov 17, 2018
0514840
Update test_insert_magic_links.py
dwitterer Nov 17, 2018
5fb05c1
Reorder insert_magic_links to autocrop urls first
dwitterer Nov 18, 2018
20cd232
Add tests for autocropping urls
dwitterer Nov 18, 2018
b91e82a
Add tests for new hashtag system and modify old ones
dwitterer Nov 18, 2018
e132d72
Modify old tests to suit new hashtag system
dwitterer Nov 18, 2018
0e7ae10
Add test case for URL autocropping with other text
dwitterer Nov 18, 2018
c64d727
Autocropping function error prevention
dwitterer Nov 20, 2018
1b9cc29
I'm an idiot
dwitterer Nov 20, 2018
4882913
I python-ed a little too hard
dwitterer Nov 20, 2018
3ff794d
Add new test cases for the anchor annihilator
dwitterer Nov 20, 2018
12af3af
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
549d100
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
0a0fb90
Update test_dweet_comments.py
dwitterer Nov 20, 2018
b3bbfa5
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
59ddbcb
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
dc4a853
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
6eea5e3
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
75ff72d
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
46c4999
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
baf715f
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
b83056f
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
a640949
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
988005d
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
400f1b4
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
e7c324a
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
99f5487
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
557ffb9
Insert missed comma
dwitterer Nov 20, 2018
af904db
Fixed lint-python errors in this file
dwitterer Nov 20, 2018
73185b5
Remove unnecessary string concatenation
dwitterer Nov 20, 2018
caf605e
Use new hashtag regex in models.py
dwitterer Nov 26, 2018
404a4c1
Make autocrop tests default to https
dwitterer Nov 26, 2018
bd67277
Made tests not fail
dwitterer Nov 26, 2018
0d856ed
Fix ordering of link insertion functions in serializers.py
dwitterer Nov 26, 2018
48f6c8c
Less confusing function names
dwitterer Nov 26, 2018
4d71b9e
Don't match invalid usernames
dwitterer Nov 26, 2018
b7d7341
New tests for username punctuation suffixing
dwitterer Nov 26, 2018
100e60a
Fix broken regexes
dwitterer Nov 26, 2018
03b17e4
Add new tests for hashtag punctuation
dwitterer Nov 26, 2018
4b76ae7
Dweet mentions can use the same punctuation rule
dwitterer Nov 26, 2018
22c8279
Add tests for dweet mention punctuation suffixing
dwitterer Nov 26, 2018
1e958c1
Typo
dwitterer Nov 26, 2018
716e0b3
Fix lint_python errors in this file
dwitterer Nov 26, 2018
23c2f3f
Fix lint-python errors in this file
dwitterer Nov 26, 2018
d4d08be
Typo
dwitterer Nov 26, 2018
9ee2aed
Fix some failing tests
dwitterer Nov 26, 2018
7e468b4
Typo
dwitterer Nov 27, 2018
910ef08
Stianjensen was right....
dwitterer Nov 27, 2018
ea6a6a7
More consistent comment formatting
dwitterer Nov 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for new hashtag system and modify old ones
We might also want to avoid matching /u/jane if there is no space between in and #yey, by making sure that all /u/ mentions have either a space or EOL after them, since a # is not a valid username character...
  • Loading branch information
dwitterer authored Nov 18, 2018
commit b91e82afbdfc59db7babe579c9b9c4fb05519d98
67 changes: 35 additions & 32 deletions dwitter/tests/templatetags/test_insert_magic_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class DweetTestCase(TestCase):

def test_insert_magic_links_bypasses_html(self):
self.assertEqual(
'prefix <h1>content</h1> suffix',
Expand Down Expand Up @@ -83,71 +83,71 @@ def test_insert_magic_links_replaces_user_inside_parenthases(self):

# autocrop (http://dwitter.net/d/1 -> d/1)

def test_insert_magic_links_autocrops_urls_d(self):
def test_insert_magic_autocrops_urls_d(self):
self.assertEqual(
'<a href="/d/123">d/123</a>',
insert_magic_links('dwitter.net/d/123')
)


def test_insert_magic_links_autocrops_urls_d_http(self):
def test_insert_magic_autocrops_urls_d_http(self):
dwitterer marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(
'<a href="/d/123">d/123</a>',
insert_magic_links('http://dwitter.net/d/123')
)


def test_insert_magic_links_autocrops_urls_d_www(self):
def test_insert_magic_autocrops_urls_d_www(self):
self.assertEqual(
'<a href="/d/123">d/123</a>',
insert_magic_links('www.dwitter.net/d/123')
)


def test_insert_magic_links_autocrops_urls_d_http_www(self):
def test_insert_magic_autocrops_urls_d_http_www(self):
self.assertEqual(
'<a href="/d/123">d/123</a>',
insert_magic_links('http://www.dwitter.net/d/123')
)


def test_insert_magic_links_autocrops_urls_d_multiple(self):
def test_insert_magic_autocrops_urls_d_multiple(self):
self.assertEqual(
'<a href="/d/123">d/123</a> <a href="/d/456">456</a>',
insert_magic_links('dwitter.net/d/123 http://dwitter.net/d/456')
)

# autocrop with u/ links

def test_insert_magic_links_autocrops_urls_u(self):
def test_insert_magic_autocrops_urls_u(self):
self.assertEqual(
'<a href="/u/yonatan">u/yonatan</a>',
insert_magic_links('dwitter.net/u/yonatan')
)


def test_insert_magic_links_autocrops_urls_u_http(self):
def test_insert_magic_autocrops_urls_u_http(self):
self.assertEqual(
'<a href="/u/veubeke">u/veubeke</a>',
insert_magic_links('http://dwitter.net/u/veubeke')
)


def test_insert_magic_links_autocrops_urls_u_www(self):
def test_insert_magic_autocrops_urls_u_www(self):
self.assertEqual(
'<a href="/u/pavel">u/pavel</a>',
insert_magic_links('www.dwitter.net/u/pavel')
)


def test_insert_magic_links_autocrops_urls_u_http_www(self):
def test_insert_magic_autocrops_urls_u_http_www(self):
self.assertEqual(
'<a href="/u/lionleaf">u/lionleaf</a>',
insert_magic_links('http://www.dwitter.net/u/lionleaf')
)


def test_insert_magic_links_autocrops_urls_u_multiple(self):
def test_insert_magic_autocrops_urls_u_multiple(self):
self.assertEqual(
'<a href="/u/sigveseb">u/sigveseb</a> <a href="/u/aemkei">u/aemkei</a>',
insert_magic_links('dwitter.net/u/sigveseb http://dwitter.net/u/aemkei')
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_insert_magic_links_replaces_dweet_in_parenthases(self):
'(<a href="/d/1">d/1</a>)',
insert_magic_links('(d/1)')
)

# hashtag

def test_insert_magic_replaces_basic_hashtag(self):
Expand All @@ -233,45 +233,52 @@ def test_insert_magic_replaces_basic_hashtag(self):
)


def test_insert_magic_replaces_prefix_hashtag(self):
def test_insert_magic_replaces_hashtag_word_prefix(self):
self.assertEqual(
'prefix <a href="/h/test">#test</a>',
insert_magic_links('prefix #test')
)


def test_insert_magic_replaces_hashtag_prefix_no_space(self):
def test_insert_magic_ignores_hashtag_prefix_no_space(self):
self.assertEqual(
'prefix<a href="/h/test">#test</a>',
'prefix#test',
insert_magic_links('prefix#test')
)


def test_insert_magic_replaces_hashtag_paren(self):
self.assertEqual(
'prefix(<a href="/h/test">#test</a>)',
insert_magic_links('prefix(#test)')
)


def test_insert_magic_replaces_hashtag_underscore(self):
self.assertEqual(
'Dwitter is just <a href="/h/amazing_underscore">#amazing_underscore</a>, right?',
insert_magic_links('Dwitter is just #amazing_underscore, right?')
)


def test_insert_magic_replaces_hashtag_illegal_hyphen(self):
def test_insert_magic_ignores_hashtag_illegal_hyphen(self):
self.assertEqual(
'Dwitter is just <a href="/h/amaze">#amaze</a>-balls, right?',
'Dwitter is just #amaze-balls, right?',
insert_magic_links('Dwitter is just #amaze-balls, right?')
)


def test_insert_magic_hashtag_not_start_with_digit(self):
def test_insert_magic_ignores_hashtag_no_letters(self):
self.assertEqual(
'Dwitter is so #1337',
lionleaf marked this conversation as resolved.
Show resolved Hide resolved
insert_magic_links('Dwitter is so #1337')
)


def test_insert_magic_hashtag_digit_start_with_letters(self):
self.assertEqual(
'We are the <a href="/h/1337elite">#1337elite</a>'
insert_magic_links('We are the #1337elite')
)


def test_insert_magic_hashtag_letters_and_digits(self):
self.assertEqual(
'Dwitter is just #1337 or <a href="/h/super1337">#super1337</a>?',
insert_magic_links('Dwitter is just #1337 or #super1337?')
'Dwitter is like <a href="/h/abc123">#abc123</a>',
insert_magic_links('Dwitter is like #abc123')
)


Expand All @@ -284,10 +291,6 @@ def test_insert_magic_single_character_hashtag(self):
'<a href="/h/S">#S</a>',
insert_magic_links('#S')
)
self.assertEqual(
'#1', # Start with digit not legal
insert_magic_links('#1')
)

# mixed

Expand All @@ -307,6 +310,6 @@ def test_insert_magic_links_mixed_hashtag(self):
'<a href="/h/amazing">#amazing</a> '
'<a href="/d/123">d/123</a> by '
'<a href="/u/jane">u/jane</a>'
'<a href="/h/yey">#yey</a>',
'#yey',
insert_magic_links('#awesome u/john remixed #amazing d/123 by /u/jane#yey')
)