From ce5b645d794811d1c0345dcd5107a0e58d61f414 Mon Sep 17 00:00:00 2001 From: Guilherme Lucas da Silva Date: Mon, 5 Oct 2020 15:45:40 -0300 Subject: [PATCH 1/2] tests: adding first tests --- tests/test_focusedme.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/test_focusedme.py b/tests/test_focusedme.py index a2d3766..0bfbd74 100644 --- a/tests/test_focusedme.py +++ b/tests/test_focusedme.py @@ -3,22 +3,23 @@ """Tests for `focusedme` package.""" import pytest - - import focusedme - +from focusedme import util @pytest.fixture -def response(): - """Sample pytest fixture. +def call_in_app_path(): + return util.in_app_path('test.txt') - See more at: http://doc.pytest.org/en/latest/fixture.html - """ - # import requests - # return requests.get('https://github.com/audreyr/cookiecutter-pypackage') +def test_in_app_path(call_in_app_path): + import pathlib + + assert call_in_app_path == str(pathlib.Path().absolute()) + '/focusedme/test.txt' + +@pytest.fixture +def call_from_resource(): + return util._from_resource('test.txt') +def test_from_resource(call_from_resource): + import pathlib -def test_content(response): - """Sample pytest test function with the pytest fixture as an argument.""" - # from bs4 import BeautifulSoup - # assert 'GitHub' in BeautifulSoup(response.content).title.string + assert call_from_resource == str(pathlib.Path().absolute()) + '/focusedme/test.txt' \ No newline at end of file From 520b4b7171967e77fdb3c5ed7c3c3f3962e1888c Mon Sep 17 00:00:00 2001 From: Guilherme Lucas da Silva Date: Wed, 7 Oct 2020 10:53:59 -0300 Subject: [PATCH 2/2] add: sound enabled as config --- config/fm.init | 3 +++ focusedme/__main__.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/config/fm.init b/config/fm.init index 73cef09..2edd038 100644 --- a/config/fm.init +++ b/config/fm.init @@ -4,3 +4,6 @@ short_break = 5 long_break = 25 num_rounds = 3 +[sound] +sound = True + diff --git a/focusedme/__main__.py b/focusedme/__main__.py index 8ebc456..62d6bbd 100644 --- a/focusedme/__main__.py +++ b/focusedme/__main__.py @@ -411,6 +411,13 @@ def load_init(): for section in list(config['time']): len_args[section] = int(config['time'][section]) + for section in list(config['sound']): + sound_enabled = str(config['sound'][section]) + + if sound_enabled: + SOUND = bool(sound_enabled) + len_args[section] = SOUND + return len_args def save_init(len_args): @@ -423,6 +430,9 @@ def save_init(len_args): for section in list(config['time']): config.set('time',section, str(len_args[section])) + for section in list(config['sound']): + config.set('sound',section, str(len_args[section])) + with open(file, 'w') as configfile: config.write(configfile) @@ -439,6 +449,7 @@ def show_init(len_args): print(View.getColor("orange") + " Short Break: " + str(len_args["short_break"])) print(View.getColor("red") + " Long Break: " + str(len_args["long_break"])) print(View.getColor("blue") + " Rounds: " + str(len_args["num_rounds"])) + print(View.getColor("purple") + " Sound: " + str(len_args["sound"])) print( View.getColor("reset") ) def main():