-
Notifications
You must be signed in to change notification settings - Fork 0
/
ciperpus_page.py
73 lines (64 loc) · 1.7 KB
/
ciperpus_page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import enum
from selenium import webdriver
from functools import wraps
class endpoints:
login = "login"
dashboard = "dashboard"
logout = "login/logout"
front_buku = "login/search_buku"
front_anggota = "login/view_anggota"
anggota = "anggota"
anggota_add = "anggota/create"
buku = "buku"
buku_add = "buku/create"
users = "users"
users_add = "users/create"
peminjaman = "peminjaman"
pengembalian = "pengembalian"
laporan_anggota = "laporan/anggota"
laporan_buku = "laporan/buku"
laporan_peminjaman = "laporan/peminjaman"
laporan_pengembalian = "laporan/pengembalian"
class ciperpus_page:
def __init__(self, client):
self.client = client
def require_login(foo):
@wraps(foo)
def wrap(self, *args, **kwargs):
if not self.client.is_logged_in:
self.client.login()
return foo(self, *args, **kwargs)
return wrap
def require_logout(foo):
@wraps(foo)
def wrap(self, *args, **kwargs):
if self.client.is_logged_in:
self.client.logout()
return foo(self, *args, **kwargs)
return wrap
@require_logout
def login(self):
self.driver.open(endpoints.login)
@property
def driver(self):
return self.client.driver
@require_login
def dashboard(self):
self.driver.open(endpoints.dashboard)
@require_login
def logout(self):
self.driver.open(endpoints.logout)
front_buku = "login/search_buku"
front_anggota = "login/view_anggota"
anggota = "anggota"
anggota_add = "anggota/create"
buku = "buku"
buku_add = "buku/create"
users = "users"
users_add = "users/create"
peminjaman = "peminjaman"
pengembalian = "pengembalian"
laporan_anggota = "laporan/anggota"
laporan_buku = "laporan/buku"
laporan_peminjaman = "laporan/peminjaman"
laporan_pengembalian = "laporan/pengembalian"