-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
55 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
*.pyc | ||
*.pylint | ||
build/ | ||
dist/ | ||
grs.egg-info/ |
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,12 +1,7 @@ | ||
language: python | ||
python: | ||
- 2.6 | ||
- 2.7 | ||
- pypy | ||
install: python setup.py install | ||
script: | ||
- python grsTestAll.py | ||
- python testopen.py | ||
- python testtwseno.py | ||
- python test_realtime.py | ||
- python test_unittest.py |
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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,48 +1,84 @@ | ||
# -*- coding: utf-8 -*- | ||
''' Unittest ''' | ||
from datetime import datetime | ||
from types import BooleanType | ||
from types import NoneType | ||
import grs | ||
import unittest | ||
|
||
|
||
class TestGrs(unittest.TestCase): | ||
def setUp(self): | ||
def get_data(self): | ||
self.stock_no = '2618' | ||
self.data = grs.Stock(self.stock_no) | ||
|
||
def test_stock(self): | ||
self.get_data() | ||
assert self.data.info[0] == self.stock_no | ||
|
||
def test_best_buy_or_sell(self): | ||
self.get_data() | ||
assert isinstance(grs.BestFourPoint(self.data).best_four_point(), | ||
(tuple, NoneType)) | ||
|
||
def test_moving_average(self): | ||
self.get_data() | ||
result = self.data.moving_average(3) | ||
assert isinstance(result[0], list) | ||
assert isinstance(result[1], int) | ||
|
||
def test_moving_average_value(self): | ||
self.get_data() | ||
result = self.data.moving_average_value(3) | ||
assert isinstance(result[0], list) | ||
assert isinstance(result[1], int) | ||
|
||
def test_moving_average_bias_ratio(self): | ||
self.get_data() | ||
result = self.data.moving_average_bias_ratio(6, 3) | ||
assert isinstance(result[0], list) | ||
assert isinstance(result[1], int) | ||
|
||
def test_check_moving_average_bias_ratio(self): | ||
self.get_data() | ||
result = self.data.check_moving_average_bias_ratio( | ||
self.data.moving_average_bias_ratio(3, 6)[0], | ||
positive_or_negative=True)[0] | ||
assert isinstance(result, BooleanType) | ||
|
||
def test_stock_value(self): | ||
self.get_data() | ||
assert isinstance(self.data.price, list) | ||
assert isinstance(self.data.openprice, list) | ||
assert isinstance(self.data.value, list) | ||
|
||
@staticmethod | ||
def test_twse_no(): | ||
twse_no = grs.TWSENo() | ||
assert isinstance(twse_no.all_stock, dict) | ||
result = twse_no.search(u'中') | ||
# 1701 中化 | ||
assert 1701 in result | ||
result = twse_no.searchbyno(17) | ||
assert 1701 in result | ||
|
||
@staticmethod | ||
def test_twse_open(): | ||
is_open = grs.TWSEOpen() | ||
result = is_open.d_day(datetime(2014, 1, 1)) | ||
assert result is False | ||
|
||
@staticmethod | ||
def test_realtime(): | ||
real_time = grs.RealtimeStock('2618') | ||
assert real_time.real['no'] == '2618' | ||
real_time = grs.RealtimeWeight() | ||
assert real_time.real['no'] == '1' | ||
|
||
@staticmethod | ||
def test_countdown(): | ||
result = grs.Countdown().countdown | ||
assert isinstance(result, int) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.