Skip to content

Commit 5f181b4

Browse files
author
Saurabh Kumar
committed
add script test
1 parent f7747fa commit 5f181b4

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# django-dotenv-rw
22

3+
[![Build Status](https://travis-ci.org/theskumar/django-dotenv-rw.svg?branch=master)](https://travis-ci.org/theskumar/django-dotenv-rw)
4+
35
Forked from awesome but simpler [django-dotenv](https://github.com/jacobian/django-dotenv). Removes black magic, makes loading .env in settings.py easier, adds remote .env file management capabilities. Works as a drop-in replacement for django-dotenv.
46

57
[foreman](https://github.com/ddollar/foreman) reads from `.env`. `manage.py`
@@ -10,7 +12,7 @@ doesn't. Let's fix that.
1012
## Installation
1113

1214
```
13-
pip install git+ssh://[email protected]/tedtieken/django-dotenv-rw.git
15+
pip install git+ssh://[email protected]/theskumar/django-dotenv-rw.git
1416
```
1517

1618
## Usage: loading settings from a .env file into your django environment

dotenv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,21 @@ def cli(file, action, key, value, force):
130130
stored_value = get_key(file, key)
131131
if stored_value:
132132
click.echo("%s=%s" % (key, stored_value))
133-
exit(1)
133+
exit(0)
134134
else:
135135
click.echo("%s doesn't seems to have been set yet.")
136-
exit(0)
136+
exit(1)
137137

138138
elif action == 'set':
139139
if not value:
140140
click.echo("Error: value is missing.")
141-
exit(0)
141+
exit(1)
142142
success, key, value = set_key(file, key, value)
143143
if success:
144144
click.echo("%s=%s" % (key, value))
145-
exit(1)
146-
else:
147145
exit(0)
146+
else:
147+
exit(1)
148148

149149
elif action == 'unset':
150150
success, key = unset_key(file, key)

tests/test_basic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ def test_read_write():
1313
stored_value = dotenv.get_key(dotenv_path, 'HELLO')
1414
assert stored_value == 'WORLD'
1515
sh.rm(dotenv_path)
16+
17+
18+
def test_script():
19+
sh.touch(dotenv_path)
20+
sh.dotenv('set', 'HELLO', 'WORLD', '-f', dotenv_path)
21+
output = sh.dotenv('get', 'HELLO', '-f', dotenv_path)
22+
assert output == 'HELLO=WORLD\n'
23+
sh.rm(dotenv_path)

0 commit comments

Comments
 (0)