Passed
Push — dev ( 3c73d5...40dcc8 )
by Konstantinos
01:24
created

conftest.load_sample_datapoints_cmd()   A

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 11
rs 9.85
c 0
b 0
f 0
cc 1
nop 2
1
import os
2
import pytest
3
4
5
my_dir = os.path.dirname(os.path.realpath(__file__))
6
7
####### Files and folders
8
@pytest.fixture
9
def tests_root_dir():
10
    return my_dir
11
12
@pytest.fixture
13
def tests_data_root(tests_root_dir):
14
    return os.path.join(tests_root_dir, 'dts')
15
16
17
@pytest.fixture
18
def sample_json(tests_data_root):
19
    return os.path.join(tests_data_root, 'sample-strains.jl')
20
21
@pytest.fixture
22
def sample_collaped_json(tests_data_root):
23
    return os.path.join(tests_data_root, 'sample-strains-colapsed.jl')
24
25
#### Objects to use for test scenarios
26
27
@pytest.fixture
28
def som_master():
29
    from green_magic.data.backend import DataEngine
30
    DataEngine.new('pd')
31
    from green_magic.strainmaster import StrainMaster
32
    return StrainMaster()
33
34
35
@pytest.fixture
36
def load_sample_datapoints_cmd(som_master, sample_json):
37
    from green_magic.data.backend import DataEngine
38
    DataEngine.new('pd')
39
    import pandas
40
    @DataEngine.pd.command
41
    def observations(file_path):
42
        return pandas.read_json(file_path, lines=True)
43
    command = som_master.commands.observations
44
    command.append_arg(sample_json)
45
    return command
46
47
48
@pytest.fixture
49
def compute_feature_vectors_cmd(som_master):
50
    command = som_master.commands.feature_vectors
51
    return command
52
53
54
@pytest.fixture
55
def sample_datapoints(som_master, load_sample_datapoints_cmd):
56
    """Use this fixture to get a Datapoints object costructed from the 'samples-strains.jl' test file in 'dts' folder."""
57
    som_master.engine.invoker.execute_command(load_sample_datapoints_cmd)
58
59
@pytest.fixture
60
def sample_feature_vectors(som_master, compute_feature_vectors_cmd):
61
    """Use this fixture to compute the feature vectors of the sample-straions.jl."""
62
    som_master.engine.invoker.execute_command(compute_feature_vectors_cmd)
63
64
65
@pytest.fixture
66
def command_invoker(green_master):
67
    return green_master.invoker
68
69
70
###### Built data to test
71
72
@pytest.fixture
73
def og_kush():
74
    from green_magic.strain.strain_class import Strain
75
    return Strain('og-kush', 'Og Kush', 'hybrid', ['flavor1', 'flavor2'], ['ef1', 'ef2'], ['n1'], ['m1', 'm2', 'm3'], ['p1', 'p2'], '100-200', '7-9', '251-500', '>2', 'Moderate', [], '')
76