mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Improve testability and file-structure
This commit is contained in:
parent
06e3c3a572
commit
e9ed89cbb1
15 changed files with 60 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -3,3 +3,6 @@ __pycache__
|
|||
|
||||
.env
|
||||
.tor_service_key
|
||||
build
|
||||
dist
|
||||
*.egg-info
|
||||
|
|
|
|||
5
DEVELOPMENT.md
Normal file
5
DEVELOPMENT.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# General File Layout
|
||||
Python/flask is not very opinionated and everything is possible. After reading (this)[https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure] and (this)[https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure] we decided for the "src-approach", at least the most obvious parts of it.
|
||||
|
||||
setup.py is not (yet) as complex as listed there and setup.cfg is not even (yet?!) existing.
|
||||
If you see this to need some improvements, please make it in small steps and explain what the benefits of all of that.
|
||||
10
README.md
10
README.md
|
|
@ -24,6 +24,9 @@ HWI support requires `libusb` (necessary? Or is `pip install libusb1` sufficient
|
|||
|
||||
```
|
||||
git clone https://github.com/cryptoadvance/specter-desktop.git
|
||||
cd specter-desktop
|
||||
virtualenv --python=python3 .env
|
||||
source .env/bin/activate
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
|
@ -34,6 +37,13 @@ cd specter-desktop
|
|||
python3 server.py
|
||||
```
|
||||
|
||||
Run the tests (still very limited):
|
||||
|
||||
```
|
||||
pip3 install -e .
|
||||
pytest
|
||||
```
|
||||
|
||||
If your Bitcoin Core is using a default data folder the app should detect it automatically. If not, consider setting `rpcuser` and `rpcpassword` in the `bitcoin.conf` file and in the app settings.
|
||||
|
||||
## A few screenshots
|
||||
|
|
|
|||
|
|
@ -23,3 +23,4 @@ stem==1.7.1
|
|||
typing-extensions==3.7.4
|
||||
urllib3==1.25.6
|
||||
Werkzeug==0.16.0
|
||||
pytest==5.2.2
|
||||
9
setup.py
Normal file
9
setup.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from setuptools import setup, find_packages
|
||||
from glob import glob
|
||||
|
||||
|
||||
setup(
|
||||
name="specter-desktop",
|
||||
packages=find_packages('src'),
|
||||
package_dir={'': 'src'}
|
||||
)
|
||||
|
|
@ -28,7 +28,7 @@ if getattr(sys, 'frozen', False):
|
|||
static_folder = os.path.join(sys._MEIPASS, 'static')
|
||||
app = Flask(__name__, template_folder=template_folder, static_folder=static_folder)
|
||||
else:
|
||||
app = Flask(__name__)
|
||||
app = Flask(__name__, template_folder="../templates", static_folder="../static")
|
||||
QRcode(app) # enable qr codes generation
|
||||
|
||||
DATA_FOLDER = "~/.specter"
|
||||
|
|
@ -506,7 +506,7 @@ if __name__ == '__main__':
|
|||
app.specter = specter
|
||||
|
||||
# watch templates folder to reload when something changes
|
||||
extra_dirs = ['templates']
|
||||
extra_dirs = ['../templates']
|
||||
extra_files = extra_dirs[:]
|
||||
for extra_dir in extra_dirs:
|
||||
for dirname, dirs, files in os.walk(extra_dir):
|
||||
30
tests/test_specter.py
Normal file
30
tests/test_specter.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
''' Tests for lovac.models '''
|
||||
import shutil
|
||||
import pytest
|
||||
from specter import Specter, alias
|
||||
|
||||
@pytest.fixture
|
||||
def specter_not_configured():
|
||||
# Make sure that this folder never ever gets a reasonable non-testing use-case
|
||||
data_folder = './test_specter_data_2789334'
|
||||
shutil.rmtree(data_folder, ignore_errors=True)
|
||||
yield Specter(data_folder=data_folder)
|
||||
shutil.rmtree(data_folder, ignore_errors=True)
|
||||
|
||||
|
||||
def test_alias():
|
||||
assert alias("wurst 1") == "wurst_1"
|
||||
assert alias("wurst_1") == "wurst_1"
|
||||
assert alias("Wurst$ 1") == "wurst_1"
|
||||
|
||||
def test_specter_permrights():
|
||||
with pytest.raises(Exception):
|
||||
Specter("/notexisting_directory")
|
||||
|
||||
def test_specter(specter_not_configured):
|
||||
specter_not_configured.check()
|
||||
assert specter_not_configured.wallets is not None
|
||||
assert specter_not_configured.devices is not None
|
||||
some_json = specter_not_configured.test_rpc()
|
||||
assert some_json["out"] == ""
|
||||
assert some_json["err"] == "autodetect failed"
|
||||
Loading…
Add table
Add a link
Reference in a new issue