Exemple #1
0
    def make_bundle(cls, settings_csv, settings_json, matrix, modified_order):
        fixtures = rel2abs(__file__, "..", "resources", "fixtures")
        bundle = rel2abs(__file__, "..", "resources", "fixtures",
                         "test_bundle")

        bundle_info = {
            "settings_csv": {
                "path": None,
                "mtime": -1,
                "status": settings_csv
            },
            "settings_json": {
                "path": None,
                "mtime": -1,
                "status": settings_json
            },
            "matrix": {
                "path": None,
                "mtime": -1,
                "status": matrix
            }
        }

        target = os.path.join(bundle, "test_bundle.settings.csv")
        bundle_info["settings_csv"]["path"] = target
        if settings_csv in ["present"] and "settings_csv" in modified_order:
            source = os.path.join(fixtures, "test_bundle.settings.csv")
            shutil.copy(source, target)
            offset = modified_order.index("settings_csv")
            mtime = (offset + 1) * 1000
            os.utime(target, (mtime, mtime))
            bundle_info["settings_csv"]["mtime"] = mtime

        target = os.path.join(bundle, "test_bundle.settings.json")
        bundle_info["settings_json"]["path"] = target
        if settings_json in ["present"] and "settings_json" in modified_order:
            source = os.path.join(fixtures, "test_bundle.settings.json")
            shutil.copy(source, target)
            offset = modified_order.index("settings_json")
            mtime = (offset + 1) * 1000
            os.utime(target, (mtime, mtime))
            bundle_info["settings_json"]["mtime"] = mtime

        target = os.path.join(bundle, "test_bundle.matrix.csv")
        bundle_info["matrix"]["path"] = target
        if matrix in ["present"] and "matrix" in modified_order:
            source = os.path.join(fixtures, "test_bundle.matrix.csv")
            shutil.copy(source, target)
            offset = modified_order.index("matrix")
            mtime = (offset + 1) * 1000
            os.utime(target, (mtime, mtime))
            bundle_info["matrix"]["mtime"] = mtime

        return bundle_info
Exemple #2
0
 def get_matrix(cls, ident):
     if ident is None or ident == "-":
         return None
     path = rel2abs(__file__, "..", "resources", "fixtures",
                    ident + ".matrix.csv")
     if os.path.exists(path):
         return load_matrix(path)
     return None
Exemple #3
0
 def get_json(cls, ident):
     if ident is None:
         return None
     path = rel2abs(__file__, "..", "resources", "fixtures", ident + ".settings.json")
     if os.path.exists(path):
         with codecs.open(path, "rb", "utf-8") as f:
             return json.loads(f.read())
     return None
Exemple #4
0
    def tear_down_bundle(cls):
        bundle = rel2abs(__file__, "..", "resources", "fixtures",
                         "test_bundle")
        settings_csv = os.path.join(bundle, "test_bundle.settings.csv")
        settings_json = os.path.join(bundle, "test_bundle.settings.json")
        matrix = os.path.join(bundle, "test_bundle.matrix.csv")

        if os.path.exists(settings_csv):
            os.remove(settings_csv)
        if os.path.exists(settings_json):
            os.remove(settings_json)
        if os.path.exists(matrix):
            os.remove(matrix)
Exemple #5
0
def load_cases():
    return load_parameter_sets(
        rel2abs(__file__, "..", "resources", "bundles", "combine"), "combine",
        "test_id", {"test_id": []})
Exemple #6
0
from combinatrix.core import CombinatrixException, combine, load_matrix
from combinatrix.test.fixtures.matrix_csv import MatrixCSVFactory
from combinatrix.test.fixtures.settings_json import SettingsJSONFactory


def load_cases():
    return load_parameter_sets(
        rel2abs(__file__, "..", "resources", "bundles", "combine"), "combine",
        "test_id", {"test_id": []})


EXCEPTIONS = {"CombinatrixException": CombinatrixException}

OUT_PATHS = {
    "none": None,
    "missing_dir": rel2abs(__file__, "path", "does", "not", "exist"),
    "available": rel2abs(__file__, "..", "resources", "tmp",
                         "combine.matrix.csv")
}


class TestCombine(unittest.TestCase):
    def setUp(self):
        super(TestCombine, self).setUp()

    def tearDown(self):
        available = OUT_PATHS["available"]
        if os.path.exists(available):
            os.remove(available)

        super(TestCombine, self).tearDown()
Exemple #7
0
import unittest, os
from parameterized import parameterized
from combinatrix.testintegration import load_parameter_sets, rel2abs
from combinatrix.core import CombinatrixException, load_matrix
from combinatrix.test.fixtures.settings_bundle import SettingsBundleFactory

EXCEPTIONS = {"CombinatrixException": CombinatrixException}

BUNDLE_PATHS = {
    "none": None,
    "not_exists": rel2abs(__file__, "path", "does", "not", "exist"),
    "exists": rel2abs(__file__, "..", "resources", "fixtures", "test_bundle")
}

BUNDLE_NAMES = {
    "none": None,
    "not_exists": "not_exists",
    "exists": "test_bundle"
}

NAME_FIELDS = {"none": None, "not_exists": "not_exists", "exists": "test_id"}

FILTERS = {
    "none": None,
    "single_filter": {
        "test_id": ["1"]
    },
    "double_filter": {
        "test_id": ["1", "2", "3"],
        "field3": ["1"]
    }
from combinatrix.testintegration import load_parameter_sets, rel2abs
from combinatrix.core import CombinatrixException, convert_csv
from combinatrix.test.fixtures.settings_csv import SettingsCSVFactory
from combinatrix.test.fixtures.settings_json import SettingsJSONFactory

def load_cases():
    return load_parameter_sets(rel2abs(__file__, "..", "resources", "bundles", "convert_csv"), "convert_csv", "test_id",
                               {"test_id" : []})

EXCEPTIONS = {
    "CombinatrixException" : CombinatrixException
}

CSV_PATHS = {
    "none" : None,
    "missing" : rel2abs(__file__, "path", "does", "not", "exist.csv")
}

PARAMS_OUT_PATHS = {
    "none" : None,
    "missing_dir" : rel2abs(__file__, "path", "does", "not", "exist"),
    "available" : rel2abs(__file__, "..", "resources", "tmp", "test_convert_csv.json")
}

class TestConvertCsv(unittest.TestCase):

    def setUp(self):
        super(TestConvertCsv, self).setUp()

    def tearDown(self):
        available = PARAMS_OUT_PATHS["available"]
 def get_csv_path(cls, ident):
     path = rel2abs(__file__, "..", "resources", "fixtures", ident + ".settings.csv")
     if os.path.exists(path):
         return path
     return None