Passed
Branch master (bc72f6)
by Rafael S.
01:23
created

TestAssetCase00   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 0
c 1
b 0
f 0
dl 0
loc 5
rs 10
1
"""Tests for Asset and Derivative."""
2
3
from __future__ import absolute_import
4
import unittest
5
6
from trade.occurrences import Asset
7
8
9
class TestAsset(unittest.TestCase):
10
    """Base class for Asset tests."""
11
12
    KINDS = {
13
        'asset': Asset,
14
    }
15
16
    kind = 'asset'
17
    symbol = None
18
    name = None
19
    expiration_date = None
20
    underlying_assets = {}
21
22
    def setUp(self):
23
        """Create the asset described in the class attrs"""
24
        self.asset = self.KINDS[self.kind](
25
            symbol=self.symbol,
26
            name=self.name,
27
            expiration_date=self.expiration_date,
28
        )
29
        if self.underlying_assets:
30
            self.asset.underlying_assets = self.underlying_assets
31
32
    def test_asset_should_exist(self):
33
        """Asset should have been created."""
34
        self.assertTrue(self.asset)
35
36
    def test_name(self):
37
        """Check the asset name."""
38
        self.assertEqual(self.asset.name, self.name)
39
40
    def test_symbol(self):
41
        """Check the asset symbol."""
42
        self.assertEqual(self.asset.symbol, self.symbol)
43
44
    def test_expiration_date(self):
45
        """Check the asset expiration date."""
46
        self.assertEqual(self.asset.expiration_date, self.expiration_date)
47
48
    def test_underlying_assets(self):
49
        """Check the underlying assets of the asset, if any."""
50
        if self.underlying_assets:
51
            self.assertEqual(
52
                self.underlying_assets,
53
                self.asset.underlying_assets
54
            )
55
56
    def test_ratio(self):
57
        """Check the ratio of the underlying assets of the asset."""
58
        if self.underlying_assets:
59
            for asset, ratio in self.underlying_assets.items():
60
                self.assertEqual(
61
                    self.asset.underlying_assets[asset],
62
                    ratio
63
                )
64
65
66
class TestAssetCase00(TestAsset):
67
    """Teste Asset Case 00 - Asset"""
68
    symbol = 'GOOG'
69
    name = None
70
    expiration_date = None
71
72
73
class TestAssetCase01(TestAsset):
74
    """Teste Asset Case 01 - Asset"""
75
76
    symbol = 'ATVI'
77
    name = 'Activision Blizzard, Inc'
78
    expiration_date = None
79
80
81
class TestAssetCase02(TestAsset):
82
    """Teste Asset Case 02 - Asset"""
83
84
    symbol = 'TEST'
85
    name = 'Some asset that expires'
86
    expiration_date = '2015-11-10'
87