arthexis 0.1.9__py3-none-any.whl → 0.1.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of arthexis might be problematic. Click here for more details.
- arthexis-0.1.26.dist-info/METADATA +272 -0
- arthexis-0.1.26.dist-info/RECORD +111 -0
- {arthexis-0.1.9.dist-info → arthexis-0.1.26.dist-info}/licenses/LICENSE +674 -674
- config/__init__.py +5 -5
- config/active_app.py +15 -15
- config/asgi.py +29 -29
- config/auth_app.py +7 -7
- config/celery.py +32 -25
- config/context_processors.py +67 -68
- config/horologia_app.py +7 -7
- config/loadenv.py +11 -11
- config/logging.py +59 -48
- config/middleware.py +71 -25
- config/offline.py +49 -49
- config/settings.py +676 -492
- config/settings_helpers.py +109 -0
- config/urls.py +228 -159
- config/wsgi.py +17 -17
- core/admin.py +4052 -2066
- core/admin_history.py +50 -50
- core/admindocs.py +192 -151
- core/apps.py +350 -223
- core/auto_upgrade.py +72 -0
- core/backends.py +311 -124
- core/changelog.py +403 -0
- core/entity.py +149 -133
- core/environment.py +60 -43
- core/fields.py +168 -75
- core/form_fields.py +75 -0
- core/github_helper.py +188 -25
- core/github_issues.py +183 -172
- core/github_repos.py +72 -0
- core/lcd_screen.py +78 -78
- core/liveupdate.py +25 -25
- core/log_paths.py +114 -100
- core/mailer.py +89 -83
- core/middleware.py +91 -91
- core/models.py +5041 -2195
- core/notifications.py +105 -105
- core/public_wifi.py +267 -227
- core/reference_utils.py +107 -0
- core/release.py +940 -346
- core/rfid_import_export.py +113 -0
- core/sigil_builder.py +149 -131
- core/sigil_context.py +20 -20
- core/sigil_resolver.py +250 -284
- core/system.py +1425 -230
- core/tasks.py +538 -199
- core/temp_passwords.py +181 -0
- core/test_system_info.py +202 -43
- core/tests.py +2673 -1069
- core/tests_liveupdate.py +17 -17
- core/urls.py +11 -11
- core/user_data.py +681 -495
- core/views.py +2484 -789
- core/widgets.py +213 -51
- nodes/admin.py +2236 -445
- nodes/apps.py +98 -70
- nodes/backends.py +160 -53
- nodes/dns.py +203 -0
- nodes/feature_checks.py +133 -0
- nodes/lcd.py +165 -165
- nodes/models.py +2375 -870
- nodes/reports.py +411 -0
- nodes/rfid_sync.py +210 -0
- nodes/signals.py +18 -0
- nodes/tasks.py +141 -46
- nodes/tests.py +5045 -1489
- nodes/urls.py +29 -13
- nodes/utils.py +172 -73
- nodes/views.py +1768 -304
- ocpp/admin.py +1775 -481
- ocpp/apps.py +25 -25
- ocpp/consumers.py +1843 -630
- ocpp/evcs.py +844 -928
- ocpp/evcs_discovery.py +158 -0
- ocpp/models.py +1417 -640
- ocpp/network.py +398 -0
- ocpp/reference_utils.py +42 -0
- ocpp/routing.py +11 -9
- ocpp/simulator.py +745 -368
- ocpp/status_display.py +26 -0
- ocpp/store.py +603 -403
- ocpp/tasks.py +479 -31
- ocpp/test_export_import.py +131 -130
- ocpp/test_rfid.py +1072 -540
- ocpp/tests.py +5494 -2296
- ocpp/transactions_io.py +197 -165
- ocpp/urls.py +50 -50
- ocpp/views.py +2024 -912
- pages/admin.py +1123 -396
- pages/apps.py +45 -10
- pages/checks.py +40 -40
- pages/context_processors.py +151 -85
- pages/defaults.py +13 -0
- pages/forms.py +221 -0
- pages/middleware.py +213 -153
- pages/models.py +720 -252
- pages/module_defaults.py +156 -0
- pages/site_config.py +137 -0
- pages/tasks.py +74 -0
- pages/tests.py +4009 -1389
- pages/urls.py +38 -20
- pages/utils.py +93 -12
- pages/views.py +1736 -762
- arthexis-0.1.9.dist-info/METADATA +0 -168
- arthexis-0.1.9.dist-info/RECORD +0 -92
- core/workgroup_urls.py +0 -17
- core/workgroup_views.py +0 -94
- nodes/actions.py +0 -70
- {arthexis-0.1.9.dist-info → arthexis-0.1.26.dist-info}/WHEEL +0 -0
- {arthexis-0.1.9.dist-info → arthexis-0.1.26.dist-info}/top_level.txt +0 -0
ocpp/test_export_import.py
CHANGED
|
@@ -1,130 +1,131 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import os
|
|
3
|
-
import tempfile
|
|
4
|
-
from datetime import timedelta
|
|
5
|
-
import io
|
|
6
|
-
|
|
7
|
-
from django.core.management import call_command
|
|
8
|
-
from django.test import TestCase
|
|
9
|
-
from django.utils import timezone
|
|
10
|
-
from django.urls import reverse
|
|
11
|
-
from django.contrib.auth import get_user_model
|
|
12
|
-
|
|
13
|
-
from ocpp.models import Charger, Transaction, MeterValue
|
|
14
|
-
from core.models import EnergyAccount
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TransactionExportImportTests(TestCase):
|
|
18
|
-
def setUp(self):
|
|
19
|
-
self.account = EnergyAccount.objects.create(name="ACC")
|
|
20
|
-
self.ch1 = Charger.objects.create(charger_id="C1")
|
|
21
|
-
self.ch2 = Charger.objects.create(charger_id="C2")
|
|
22
|
-
now = timezone.now()
|
|
23
|
-
self.tx_old = Transaction.objects.create(
|
|
24
|
-
charger=self.ch1,
|
|
25
|
-
account=self.account,
|
|
26
|
-
start_time=now - timedelta(days=5),
|
|
27
|
-
)
|
|
28
|
-
self.tx_new = Transaction.objects.create(
|
|
29
|
-
charger=self.ch2,
|
|
30
|
-
start_time=now,
|
|
31
|
-
)
|
|
32
|
-
MeterValue.objects.create(
|
|
33
|
-
charger=self.ch1,
|
|
34
|
-
transaction=self.tx_old,
|
|
35
|
-
timestamp=now - timedelta(days=5),
|
|
36
|
-
energy=1,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
def test_export_filters_and_import_creates_chargers(self):
|
|
40
|
-
with tempfile.NamedTemporaryFile(delete=False) as tmp:
|
|
41
|
-
tmp_path = tmp.name
|
|
42
|
-
|
|
43
|
-
start = (timezone.now() - timedelta(days=1)).date().isoformat()
|
|
44
|
-
call_command(
|
|
45
|
-
"export_transactions",
|
|
46
|
-
tmp_path,
|
|
47
|
-
"--start",
|
|
48
|
-
start,
|
|
49
|
-
"--chargers",
|
|
50
|
-
self.ch2.charger_id,
|
|
51
|
-
)
|
|
52
|
-
with open(tmp_path, "r", encoding="utf-8") as fh:
|
|
53
|
-
data = json.load(fh)
|
|
54
|
-
self.assertEqual(len(data["transactions"]), 1)
|
|
55
|
-
self.assertEqual(data["transactions"][0]["charger"], "C2")
|
|
56
|
-
|
|
57
|
-
MeterValue.objects.all().delete()
|
|
58
|
-
Transaction.objects.all().delete()
|
|
59
|
-
Charger.objects.all().delete()
|
|
60
|
-
|
|
61
|
-
call_command("import_transactions", tmp_path)
|
|
62
|
-
os.remove(tmp_path)
|
|
63
|
-
|
|
64
|
-
self.assertTrue(Charger.objects.filter(charger_id="C2").exists())
|
|
65
|
-
self.assertEqual(Transaction.objects.count(), 1)
|
|
66
|
-
tx = Transaction.objects.first()
|
|
67
|
-
self.assertEqual(tx.charger.charger_id, "C2")
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class TransactionAdminExportImportTests(TestCase):
|
|
71
|
-
def setUp(self):
|
|
72
|
-
self.account = EnergyAccount.objects.create(name="ACC")
|
|
73
|
-
self.ch1 = Charger.objects.create(charger_id="C1")
|
|
74
|
-
self.ch2 = Charger.objects.create(charger_id="C2")
|
|
75
|
-
now = timezone.now()
|
|
76
|
-
Transaction.objects.create(
|
|
77
|
-
charger=self.ch1,
|
|
78
|
-
account=self.account,
|
|
79
|
-
start_time=now - timedelta(days=2),
|
|
80
|
-
)
|
|
81
|
-
Transaction.objects.create(
|
|
82
|
-
charger=self.ch2,
|
|
83
|
-
start_time=now,
|
|
84
|
-
)
|
|
85
|
-
User = get_user_model()
|
|
86
|
-
self.admin = User.objects.create_superuser(
|
|
87
|
-
username="txadmin", email="txadmin@example.com", password="pwd"
|
|
88
|
-
)
|
|
89
|
-
self.client.force_login(self.admin)
|
|
90
|
-
|
|
91
|
-
def test_admin_export_filters(self):
|
|
92
|
-
url = reverse("admin:ocpp_transaction_export")
|
|
93
|
-
start = (timezone.now() - timedelta(days=1)).isoformat()
|
|
94
|
-
response = self.client.post(
|
|
95
|
-
url,
|
|
96
|
-
{"start": start, "chargers": [self.ch2.pk]},
|
|
97
|
-
)
|
|
98
|
-
self.assertEqual(response.status_code, 200)
|
|
99
|
-
data = json.loads(response.content)
|
|
100
|
-
self.assertEqual(len(data["transactions"]), 1)
|
|
101
|
-
self.assertEqual(data["transactions"][0]["charger"], "C2")
|
|
102
|
-
|
|
103
|
-
def test_admin_import_creates_charger(self):
|
|
104
|
-
url = reverse("admin:ocpp_transaction_import")
|
|
105
|
-
payload = {
|
|
106
|
-
"chargers": [
|
|
107
|
-
{"charger_id": "C9", "connector_id": 1, "require_rfid": False}
|
|
108
|
-
],
|
|
109
|
-
"transactions": [
|
|
110
|
-
{
|
|
111
|
-
"charger": "C9",
|
|
112
|
-
"account": None,
|
|
113
|
-
"rfid": "",
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
json_file
|
|
125
|
-
|
|
126
|
-
self.
|
|
127
|
-
self.
|
|
128
|
-
self.
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import tempfile
|
|
4
|
+
from datetime import timedelta
|
|
5
|
+
import io
|
|
6
|
+
|
|
7
|
+
from django.core.management import call_command
|
|
8
|
+
from django.test import TestCase
|
|
9
|
+
from django.utils import timezone
|
|
10
|
+
from django.urls import reverse
|
|
11
|
+
from django.contrib.auth import get_user_model
|
|
12
|
+
|
|
13
|
+
from ocpp.models import Charger, Transaction, MeterValue
|
|
14
|
+
from core.models import EnergyAccount
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TransactionExportImportTests(TestCase):
|
|
18
|
+
def setUp(self):
|
|
19
|
+
self.account = EnergyAccount.objects.create(name="ACC")
|
|
20
|
+
self.ch1 = Charger.objects.create(charger_id="C1")
|
|
21
|
+
self.ch2 = Charger.objects.create(charger_id="C2")
|
|
22
|
+
now = timezone.now()
|
|
23
|
+
self.tx_old = Transaction.objects.create(
|
|
24
|
+
charger=self.ch1,
|
|
25
|
+
account=self.account,
|
|
26
|
+
start_time=now - timedelta(days=5),
|
|
27
|
+
)
|
|
28
|
+
self.tx_new = Transaction.objects.create(
|
|
29
|
+
charger=self.ch2,
|
|
30
|
+
start_time=now,
|
|
31
|
+
)
|
|
32
|
+
MeterValue.objects.create(
|
|
33
|
+
charger=self.ch1,
|
|
34
|
+
transaction=self.tx_old,
|
|
35
|
+
timestamp=now - timedelta(days=5),
|
|
36
|
+
energy=1,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
def test_export_filters_and_import_creates_chargers(self):
|
|
40
|
+
with tempfile.NamedTemporaryFile(delete=False) as tmp:
|
|
41
|
+
tmp_path = tmp.name
|
|
42
|
+
|
|
43
|
+
start = (timezone.now() - timedelta(days=1)).date().isoformat()
|
|
44
|
+
call_command(
|
|
45
|
+
"export_transactions",
|
|
46
|
+
tmp_path,
|
|
47
|
+
"--start",
|
|
48
|
+
start,
|
|
49
|
+
"--chargers",
|
|
50
|
+
self.ch2.charger_id,
|
|
51
|
+
)
|
|
52
|
+
with open(tmp_path, "r", encoding="utf-8") as fh:
|
|
53
|
+
data = json.load(fh)
|
|
54
|
+
self.assertEqual(len(data["transactions"]), 1)
|
|
55
|
+
self.assertEqual(data["transactions"][0]["charger"], "C2")
|
|
56
|
+
|
|
57
|
+
MeterValue.objects.all().delete()
|
|
58
|
+
Transaction.objects.all().delete()
|
|
59
|
+
Charger.objects.all().delete()
|
|
60
|
+
|
|
61
|
+
call_command("import_transactions", tmp_path)
|
|
62
|
+
os.remove(tmp_path)
|
|
63
|
+
|
|
64
|
+
self.assertTrue(Charger.objects.filter(charger_id="C2").exists())
|
|
65
|
+
self.assertEqual(Transaction.objects.count(), 1)
|
|
66
|
+
tx = Transaction.objects.first()
|
|
67
|
+
self.assertEqual(tx.charger.charger_id, "C2")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class TransactionAdminExportImportTests(TestCase):
|
|
71
|
+
def setUp(self):
|
|
72
|
+
self.account = EnergyAccount.objects.create(name="ACC")
|
|
73
|
+
self.ch1 = Charger.objects.create(charger_id="C1")
|
|
74
|
+
self.ch2 = Charger.objects.create(charger_id="C2")
|
|
75
|
+
now = timezone.now()
|
|
76
|
+
Transaction.objects.create(
|
|
77
|
+
charger=self.ch1,
|
|
78
|
+
account=self.account,
|
|
79
|
+
start_time=now - timedelta(days=2),
|
|
80
|
+
)
|
|
81
|
+
Transaction.objects.create(
|
|
82
|
+
charger=self.ch2,
|
|
83
|
+
start_time=now,
|
|
84
|
+
)
|
|
85
|
+
User = get_user_model()
|
|
86
|
+
self.admin = User.objects.create_superuser(
|
|
87
|
+
username="txadmin", email="txadmin@example.com", password="pwd"
|
|
88
|
+
)
|
|
89
|
+
self.client.force_login(self.admin)
|
|
90
|
+
|
|
91
|
+
def test_admin_export_filters(self):
|
|
92
|
+
url = reverse("admin:ocpp_transaction_export")
|
|
93
|
+
start = (timezone.now() - timedelta(days=1)).isoformat()
|
|
94
|
+
response = self.client.post(
|
|
95
|
+
url,
|
|
96
|
+
{"start": start, "chargers": [self.ch2.pk]},
|
|
97
|
+
)
|
|
98
|
+
self.assertEqual(response.status_code, 200)
|
|
99
|
+
data = json.loads(response.content)
|
|
100
|
+
self.assertEqual(len(data["transactions"]), 1)
|
|
101
|
+
self.assertEqual(data["transactions"][0]["charger"], "C2")
|
|
102
|
+
|
|
103
|
+
def test_admin_import_creates_charger(self):
|
|
104
|
+
url = reverse("admin:ocpp_transaction_import")
|
|
105
|
+
payload = {
|
|
106
|
+
"chargers": [
|
|
107
|
+
{"charger_id": "C9", "connector_id": 1, "require_rfid": False}
|
|
108
|
+
],
|
|
109
|
+
"transactions": [
|
|
110
|
+
{
|
|
111
|
+
"charger": "C9",
|
|
112
|
+
"account": None,
|
|
113
|
+
"rfid": "",
|
|
114
|
+
"vid": "",
|
|
115
|
+
"vin": "",
|
|
116
|
+
"meter_start": 0,
|
|
117
|
+
"meter_stop": 0,
|
|
118
|
+
"start_time": timezone.now().isoformat(),
|
|
119
|
+
"stop_time": None,
|
|
120
|
+
"meter_values": [],
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
}
|
|
124
|
+
json_file = io.StringIO(json.dumps(payload))
|
|
125
|
+
json_file.name = "tx.json"
|
|
126
|
+
response = self.client.post(url, {"file": json_file})
|
|
127
|
+
self.assertEqual(response.status_code, 302)
|
|
128
|
+
self.assertTrue(Charger.objects.filter(charger_id="C9").exists())
|
|
129
|
+
self.assertEqual(
|
|
130
|
+
Transaction.objects.filter(charger__charger_id="C9").count(), 1
|
|
131
|
+
)
|