aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/__main__.py
blob: 39ef0d164cca4e7541be2fce8e1be9cbcf6be77c (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the sgdfi project, which is MIT-licensed.
#******************************************************************************
""" Main script for testing things with SGDFi. """

import os.path as _path

def get_session():
	""" Get a logged in session. """

	from . import Session as _Session

	path = _path.join(_path.dirname(__file__), '..', '..', 'logins.txt')
	user, pw = (x.splitlines()[0] for x in open(path).readlines())

	return _Session(user = user, pw = pw, save = True)

def test_session():
	""" Test the session. """

	s = get_session()

	#ret = s.get_ops('4', "yCbyTmNDHpp8CotDhWoEkQ==")
	#ret = s.get_place('ONCt5ZDoIUZIXlYv9QyGuw==')
	ret = s.get_structure('oA0pOxhIxVX5eh6fTNvgzg==')

	if type(ret) == list:
		for e in ret:
			print(e)
			print()
	else:
		print(ret)

def test_repr():
	""" Test the representations. """

	from datetime import datetime as _datetime
	from ._repr import Operation as _Operation, Adherent as _Adherent, \
		Function as _Function

	op = _Operation()
	op.time = _datetime(2018, 10, 1, 0, 17, 38)
	op.type = "Individu / Abonnement "
	op.author = "LEFEBVRE CAROLE"
	op.fields = "Revue: Revue Louveteau-Jeannette, Type: Gratuit, " \
		"Fin: 31/08/2019, Prix: 0,00€ "

	ad = _Adherent()
	ad.iid = "yCbyTmNDHpp8CotDhWoEkQ=="
	ad.function = _Function.CHEF_PIONNIER_CARAVELLE
	print(ad)

	op.related.add(ad)

def test_save():
	""" Test the saving. """

	from ._manager import Manager

	man = Manager(save = True)
	man.save("hello world", ext = "html")

def test_load():
	""" Test the loading. """

	from ._manager import Manager

	man = Manager()
	ret = man.load_dump("2018100414530000-functions.xml")

	if type(ret) == list:
		for e in ret:
			print(e)
			print()
	else:
		print(ret)

def test_funcs():
	""" Test getting the functions. """

	s = get_session()

	f = s.get_functions()
	s.export_functions(f)

if __name__ == '__main__':
	test_repr()
	#test_session()
	#test_save()
	#test_load()
	#test_funcs()

# End of file.