mirror of
https://github.com/bspeice/metrik
synced 2025-07-01 05:46:22 -04:00
Initial commit for metrik
This commit is contained in:
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
40
test/targets/pickle_target.py
Normal file
40
test/targets/pickle_target.py
Normal file
@ -0,0 +1,40 @@
|
||||
from unittest import TestCase
|
||||
import luigi
|
||||
from metrik.targets.pickle_target import PickleTarget
|
||||
|
||||
|
||||
class FibTask(luigi.Task):
|
||||
s = luigi.IntParameter()
|
||||
|
||||
def requires(self):
|
||||
if self.s >= 2:
|
||||
return [FibTask(self.s - 1), FibTask(self.s - 2)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def output(self):
|
||||
return PickleTarget(self.task_id)
|
||||
|
||||
def run(self):
|
||||
if self.s <= 1:
|
||||
val = self.s
|
||||
else:
|
||||
count = 0
|
||||
for input in self.input():
|
||||
count += input.read()
|
||||
val = count
|
||||
|
||||
self.output().write(val)
|
||||
|
||||
|
||||
class TestPickleTarget(TestCase):
|
||||
def test_fibonacci(self):
|
||||
f = FibTask(6)
|
||||
luigi.build([f], local_scheduler=True)
|
||||
|
||||
ret = f.output().read()
|
||||
assert ret == 8
|
||||
|
||||
f = FibTask(100)
|
||||
luigi.build([f], local_scheduler=True)
|
||||
assert f.output().read() == 354224848179261915075
|
0
test/tasks/__init__.py
Normal file
0
test/tasks/__init__.py
Normal file
22
test/tasks/test_bloomberg.py
Normal file
22
test/tasks/test_bloomberg.py
Normal file
@ -0,0 +1,22 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from metrik.conf import USER_AGENT
|
||||
from metrik.tasks.bloomberg import BloombergEquityInfo
|
||||
|
||||
|
||||
class BloombergTest(TestCase):
|
||||
def test_correct_info_apple(self):
|
||||
sector, industry, sub_industry = \
|
||||
BloombergEquityInfo.retrieve_info("AAPL:US", USER_AGENT)
|
||||
|
||||
assert sector == 'Technology'
|
||||
assert industry == 'Hardware'
|
||||
assert sub_industry == 'Communications Equipment'
|
||||
|
||||
def test_correct_info_kcg(self):
|
||||
sector, industry, sub_industry = \
|
||||
BloombergEquityInfo.retrieve_info("KCG:US", USER_AGENT)
|
||||
|
||||
assert sector == 'Financials'
|
||||
assert industry == 'Institutional Financial Svcs'
|
||||
assert sub_industry == 'Institutional Brokerage'
|
Reference in New Issue
Block a user