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

Menambahkan galat ketika akun dibekukan #23

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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