Skip to content

Commit

Permalink
We no longer know whether profiles are suspended
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Jun 17, 2020
1 parent bc0ccb4 commit 51c7af0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ proc parseProfile(js: JsonNode; id=""): Profile =
result.expandProfileEntities(js)

proc parseUserLookup*(js: JsonNode; username: string): Profile =
if js.isNull or js.kind == JArray and js.len == 0: return
with error, js{"errors"}:
result = Profile(username: username)
if error.getError == suspended:
result.suspended = true
return

if js.isNull or js.kind == JArray and js.len == 0 or "error" in js:
return Profile(username: username)
result = parseProfile(js[0])

proc parseGraphProfile*(js: JsonNode; username: string): Profile =
Expand Down
1 change: 1 addition & 0 deletions src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type

Error* = enum
null = 0
noUserMatches = 17
protectedUser = 22
couldntAuth = 32
doesntExist = 34
Expand Down
6 changes: 3 additions & 3 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def test_invalid_username(self, username):
self.open_nitter(username)
self.assert_text(f'User "{username}" not found')

def test_suspended(self):
self.open_nitter('test')
self.assert_text('User "test" has been suspended')
# def test_suspended(self):
# self.open_nitter('test')
# self.assert_text('User "test" has been suspended')

@parameterized.expand(banner_color)
def test_banner_color(self, username, color):
Expand Down

0 comments on commit 51c7af0

Please sign in to comment.