-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matheus Fernandes <matheus.souza.fernandes@gmail.com>
- Loading branch information
1 parent
cfa095b
commit eac6381
Showing
6 changed files
with
62 additions
and
2 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
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,41 @@ | ||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
from mock import patch | ||
from api.sensor import SensorAPI | ||
import requests | ||
|
||
|
||
class TestSensor(TestCase): | ||
|
||
data = b'[{"type": [1, "themal"], "id": 4, "position": [1, "lower"], '\ | ||
b'"location": [2, "second_pot"]}]' | ||
data_list = [{"type": [1, "themal"], | ||
"id": 4, "position": [1, "lower"], | ||
"location": [2, "second_pot"]}] | ||
|
||
def setUp(self): | ||
self.api = SensorAPI() | ||
|
||
@override_settings(API_URL='http://api.com') | ||
def test_get_url(self): | ||
url = self.api.get_url() | ||
self.assertEquals(url, 'http://api.com/sensors/') | ||
|
||
@override_settings(API_URL='http://api.com') | ||
def test_get_url_with_sensor_id(self): | ||
url = self.api.get_url(sensor_id=1) | ||
self.assertEquals(url, 'http://api.com/sensors/1/') | ||
|
||
@patch.object(requests, 'get') | ||
def test_get_data(self, mock): | ||
response = requests.Response() | ||
response._content = self.data | ||
mock.return_value = response | ||
|
||
sensor_data = self.api.get_data(self.api.get_url()) | ||
self.assertEquals(sensor_data, self.data_list) | ||
|
||
@patch.object(SensorAPI, 'get_data') | ||
def test_all(self, mock): | ||
mock.return_value = self.data_list | ||
self.assertEquals(self.api.all(), self.data_list) |
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,19 @@ | ||
from django.test import TestCase | ||
from defaults.forms import FGABrejaForm | ||
from mock import Mock | ||
|
||
|
||
class TestDefaultsForm(TestCase): | ||
|
||
def setUp(self): | ||
self.data = {'data': 'data', } | ||
request = Mock(POST=self.data) | ||
self.form = FGABrejaForm(request) | ||
|
||
def test_is_valid(self): | ||
with self.assertRaises(NotImplementedError): | ||
self.form.is_valid() | ||
|
||
def test_save(self): | ||
with self.assertRaises(NotImplementedError): | ||
self.form.save() |
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 +1 @@ | ||
API_URL = 'localhost:5000' | ||
API_URL = 'http://localhost:5000' |