From 913aac26ca43778e14701834940f69e6f7ba7410 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 16 Oct 2021 20:44:56 +1100 Subject: [PATCH] Fix unit tests --- eos/core/tests.py | 4 +++- eos/tests.py | 6 +++--- js.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/eos/core/tests.py b/eos/core/tests.py index e818a40..7d2330c 100644 --- a/eos/core/tests.py +++ b/eos/core/tests.py @@ -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): diff --git a/eos/tests.py b/eos/tests.py index 5855301..1daebab 100644 --- a/eos/tests.py +++ b/eos/tests.py @@ -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): diff --git a/js.html b/js.html index 93c6491..d01258f 100644 --- a/js.html +++ b/js.html @@ -1 +1 @@ - +