Skip to content

Commit ae6dd82

Browse files
author
Max Waldt
authored
Merge pull request #72 from EasyPost/fix_user_tests
Updating user tests and examples
2 parents 4bbdd73 + 7e46aff commit ae6dd82

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.cache
12
.DS_Store
23
.AppleDouble
34
.LSOverride
@@ -6,6 +7,9 @@ Icon
67
.Spotlight-V100
78
.Trashes
89

10+
# virtual environment
11+
venv
12+
913
/build
1014
/dist
1115
/MANIFEST
@@ -20,4 +24,4 @@ Icon
2024
test
2125
virtualenv
2226
.virtualenv
23-
.idea
27+
.idea

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### NEXT (unreleased)
22

3+
### 3.6.4 2018-04-09
4+
5+
* Update user tests
6+
37
### 3.6.3 2018-02-05
48

59
* Fix issue with responses that contain an `api_key` field (gh-67)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.6.3
1+
3.6.4

examples/user.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
child_user = easypost.User.create(
77
name='Python All-Things-Testing',
8-
password='password1',
9-
password_confirmation='password1',
10-
phone_number='7778675309'
8+
phone_number='555-555-5555'
119
)
1210
id = child_user.id
1311

tests/test_user.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
# Unit tests related to 'Users' (https://www.easypost.com/docs/api#users).
22

33
import easypost
4+
import pytest
45

56

67
def test_child_user_create(prod_api_key):
78
# Create an address and then verify some fields to test whether it was created just fine.
89
child_user = easypost.User.create(
9-
name='Python All-Things-Testing',
10-
password='password1',
11-
password_confirmation='password1',
10+
name='Python All-Things-Testing'
1211
)
12+
13+
with pytest.raises(easypost.Error) as caught_exception:
14+
easypost.User.create(
15+
name='Python All-Things-Testing',
16+
password='super-secret-password',
17+
password_confirmation='super-secret-password'
18+
)
19+
20+
exception = caught_exception.value.json_body
21+
error_msg = 'Child users must be created via the API and must not contain an email or password.'
22+
assert exception['error']['message'] == error_msg
23+
assert exception['error']['code'] == 'USER.INVALID'
24+
1325
child_id = child_user.id
1426
assert child_id is not None
1527

0 commit comments

Comments
 (0)