Fix unit tests

This commit is contained in:
RunasSudo 2021-10-16 20:44:56 +11:00
parent fc4366c028
commit 913aac26ca
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
# Eos - Verifiable elections
# Copyright © 2017-18 RunasSudo (Yingtong Li)
# Copyright © 2017-2021 RunasSudo (Yingtong Li)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -133,6 +133,7 @@ class TaskTestCase(EosTestCase):
def setUpClass(cls):
cls.db_connect_and_reset()
@py_only
def test_normal(self):
class TaskNormal(Task):
result = StringField()
@ -149,6 +150,7 @@ class TaskTestCase(EosTestCase):
self.assertEqual(task.messages[0], 'Hello World')
self.assertEqual(task.result, 'Success')
@py_only
def test_error(self):
class TaskError(Task):
def _run(self):

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# Eos - Verifiable elections
# Copyright © 2017 RunasSudo (Yingtong Li)
# Copyright © 2017-2021 RunasSudo (Yingtong Li)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -43,9 +43,9 @@ class BasePyTestCase(TestCase):
class BaseJSTestCase(TestCase):
@classmethod
def setUpClass(cls):
with open('eos/__javascript__/eos.js_tests.js', 'r') as f:
with open('eosweb/core/static/js/eosjs.js', 'r') as f:
code = f.read()
cls.ctx = execjs.get().compile('var window={},navigator={};' + code + 'var test=window.eosjs_tests.' + cls.module + '.__all__.' + cls.name + '();test.setUpClass();')
cls.ctx = execjs.get().compile('var window={},navigator={};' + code + 'var eosjs=require("eosjs");var test=eosjs.' + cls.module + '.' + cls.name + '();test.setUpClass();')
@classmethod
def add_method(cls, method):

View File

@ -1 +1 @@
<script src="eos/__javascript__/eos.js_tests.js"></script>
<script src="eosweb/core/static/js/eosjs.js"></script>