Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 71caf5d

Browse files
tyjakboogheta
authored andcommitted
Add some tests for cmdline.py
1 parent ce7c91a commit 71caf5d

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

tests/test_cmdline.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# encoding: utf-8
2+
3+
import json
4+
import re
5+
6+
try:
7+
import HTMLParser
8+
except ImportError:
9+
import html.parser as HTMLParser
10+
11+
from twitter.cmdline import (
12+
replaceInStatus,
13+
StatusFormatter,
14+
VerboseStatusFormatter,
15+
JSONStatusFormatter,
16+
)
17+
18+
19+
status = {
20+
"created_at": "sun dec 20 18:33:30 +0000 2020",
21+
"user": {"screen_name": "myusername", "location": "Paris"},
22+
"text": "test & test",
23+
}
24+
25+
26+
def test_replaceInStatus():
27+
status = "my&status @twitter #tag"
28+
assert replaceInStatus(status) == "my&status @twitter #tag"
29+
30+
31+
def test_StatusFormatter():
32+
test_status = StatusFormatter()
33+
options = {"timestamp": True, "datestamp": False}
34+
assert test_status(status, options) == "20:33:30 @myusername test & test"
35+
36+
37+
def test_VerboseStatusFormatter():
38+
test_status = VerboseStatusFormatter()
39+
options = {"timestamp": True, "datestamp": False}
40+
assert (
41+
test_status(status, options)
42+
== "-- myusername (Paris) on sun dec 20 18:33:30 +0000 2020\ntest & test\n"
43+
)
44+
45+
46+
def test_JSONStatusFormatter():
47+
test_status = JSONStatusFormatter()
48+
options = {"timestamp": True, "datestamp": False}
49+
assert test_status(status, options) == json.dumps(
50+
{
51+
"created_at": "sun dec 20 18:33:30 +0000 2020",
52+
"user": {"screen_name": "myusername", "location": "Paris"},
53+
"text": "test & test",
54+
}
55+
)

0 commit comments

Comments
 (0)