Skip to content

Commit

Permalink
Menambahkan galat ketika akun dibekukan
Browse files Browse the repository at this point in the history
  • Loading branch information
isogram authored and laymonage committed Apr 27, 2021
1 parent ea1cd03 commit 52c338a
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kbbi/kbbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def _cek_galat(self, laman):
raise TerjadiKesalahan()
if "Beranda/BatasSehari" in laman.url:
raise BatasSehari()
if "Account/Banned" in laman.url:
raise AkunDibekukan()
if "Entri tidak ditemukan." in laman.text:
self._init_saran(laman)
raise TidakDitemukan(self.nama, objek=self)
Expand Down Expand Up @@ -601,6 +603,19 @@ def __init__(self):
)


class AkunDibekukan(Galat):
"""Galat ketika Akun sedang dibekukan.
Akun dapat dibekukan secara otomatis oleh sistem keamanan KBBI Daring
atau secara manual oleh salah satu dari administrator
jika terdapat aktivitas akun yang dianggap mencurigakan.
Laman: https://kbbi.kemdikbud.go.id/Account/Banned
"""

def __init__(self):
super().__init__("Akun ini sedang dibekukan, tidak dapat digunakan.")


class GagalAutentikasi(Galat):
"""Galat ketika gagal melakukan autentikasi dengan KBBI."""

Expand Down
152 changes: 152 additions & 0 deletions tests/html/Account/Banned.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/test_kbbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def test_galat_batas_sehari():
)


def test_galat_akun_dibekukan():
with pytest.raises(kbbi.AkunDibekukan) as e:
MockKBBI("coba", lokasi="Account/Banned.html")
assert str(e.value) == (
"Akun ini sedang dibekukan, tidak dapat digunakan."
)


def test_galat_tidak_ditemukan():
with pytest.raises(kbbi.TidakDitemukan) as e:
MockKBBI("nonexistent", lokasi="entri.html")
Expand Down

0 comments on commit 52c338a

Please sign in to comment.