-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from xalien10/stage
Stage
- Loading branch information
Showing
8 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
munch>=2.5.0 | ||
requests>=2.21.0 | ||
urllib3>=1.24.3 | ||
requests-toolbelt>= 0.9.1 | ||
pytest>=6.2.2 | ||
pytest-order>=0.10.0 | ||
wheel>=0.36.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import collections | ||
import json | ||
import unittest | ||
from unittest.mock import patch | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
|
||
|
||
def get_credentials(): | ||
""" | ||
Checks and returns if dependencies for running tests resolved or not | ||
:return: tuple(str,str) | ||
""" | ||
access_token = os.getenv('FORTNOX_ACCESS_TOKEN') | ||
client_secret = os.getenv('FORTNOX_CLIENT_SECRET') | ||
if not access_token: | ||
raise ValueError("You must set `FORTNOX_ACCESS_TOKEN` environment variables") | ||
if not client_secret: | ||
raise ValueError("You must set `FORTNOX_CLIENT_SECRET` environment variables") | ||
return access_token, client_secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
import pytest | ||
|
||
import fortnox | ||
from tests.services.commons import get_credentials | ||
|
||
|
||
class EmployeeServiceTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
token, secret = get_credentials() | ||
self.client = fortnox.Client(access_token=token, client_secret=secret) | ||
self.valid_data = { | ||
'EmployeeId': '007', | ||
'FirstName': 'John', | ||
'LastName': 'Doe', | ||
'HourlyPay': '500', | ||
} | ||
|
||
@pytest.mark.order(0) | ||
def test_employee_create(self): | ||
try: | ||
employee = self.client.employees.create(**self.valid_data) | ||
except Exception as e: | ||
pass | ||
else: | ||
self.assertTrue(employee) | ||
self.assertEqual(employee.FirstName, self.valid_data['FirstName']) | ||
self.assertEqual(employee.LastName, self.valid_data['LastName']) | ||
self.assertEqual(employee.HourlyPay, self.valid_data['HourlyPay']) | ||
|
||
@pytest.mark.order(1) | ||
def test_employee_retrieve(self): | ||
employee = self.client.employees.retrieve(id='007') | ||
self.assertTrue(employee) | ||
self.assertEqual(employee.FirstName, self.valid_data['FirstName']) | ||
self.assertEqual(employee.LastName, self.valid_data['LastName']) | ||
self.assertEqual(str(employee.HourlyPay), self.valid_data['HourlyPay']) | ||
|
||
@pytest.mark.order(2) | ||
def test_employee_update(self): | ||
data = self.valid_data | ||
data.update({'id': '007'}) | ||
employee = self.client.employees.update(**data) | ||
self.assertTrue(employee) | ||
self.assertEqual(employee.FirstName, self.valid_data['FirstName']) | ||
self.assertEqual(employee.LastName, self.valid_data['LastName']) | ||
self.assertEqual(employee.HourlyPay, self.valid_data['HourlyPay']) | ||
|
||
@pytest.mark.order(3) | ||
def test_employee_list(self): | ||
employees = self.client.employees.list() | ||
self.assertTrue(employees) |