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

Commit fa08538

Browse files
tyjakboogheta
authored andcommitted
Fix test
1 parent 71caf5d commit fa08538

1 file changed

Lines changed: 38 additions & 37 deletions

File tree

tests/test_cmdline.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import json
44
import re
5+
import unittest
6+
from mock import patch
57

68
try:
79
import HTMLParser
@@ -16,40 +18,39 @@
1618
)
1719

1820

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-
)
21+
class TestCmdLine(unittest.TestCase):
22+
23+
status = {
24+
"created_at": "sun dec 20 18:33:30 +0000 2020",
25+
"user": {"screen_name": "myusername", "location": "Paris, France"},
26+
"text": "test & test",
27+
}
28+
29+
def test_replaceInStatus(self):
30+
status = "my&status @twitter #tag"
31+
assert replaceInStatus(status) == "my&status @twitter #tag"
32+
33+
@patch("twitter.cmdline.get_time_string", return_value="18:33:30 ")
34+
def test_StatusFormatter(self, mock_get_time_string):
35+
test_status = StatusFormatter()
36+
options = {"timestamp": True, "datestamp": False}
37+
assert test_status(self.status, options) == "18:33:30 @myusername test & test"
38+
39+
def test_VerboseStatusFormatter(self):
40+
test_status = VerboseStatusFormatter()
41+
options = {"timestamp": True, "datestamp": False}
42+
assert (
43+
test_status(self.status, options)
44+
== "-- myusername (Paris, France) on sun dec 20 18:33:30 +0000 2020\ntest & test\n"
45+
)
46+
47+
def test_JSONStatusFormatter(self):
48+
test_status = JSONStatusFormatter()
49+
options = {"timestamp": True, "datestamp": False}
50+
assert test_status(self.status, options) == json.dumps(
51+
{
52+
"created_at": "sun dec 20 18:33:30 +0000 2020",
53+
"user": {"screen_name": "myusername", "location": "Paris, France"},
54+
"text": "test & test",
55+
}
56+
)

0 commit comments

Comments
 (0)