<gh_stars>1-10
from Jumpscale import j


def main(self):
    """
    to run:

    kosmos 'j.data.bcdb.test(name="models")'

    work with toml files and see if models get generated properly

    """
    mpath = self._dirpath + "/tests/models"
    assert j.sal.fs.exists(mpath)

    # make sure we remove the maybe already previously generated model file
    for item in j.sal.fs.listFilesInDir(mpath, filter="*.py"):
        j.sal.fs.remove(item)

    bcdb, _ = self._load_test_model()

    bcdb.models_add(mpath)

    model = bcdb.model_get_from_url("jumpscale.bcdb.test.house")

    model_obj = model.new()
    model_obj.cost = "10 USD"
    model_obj.save()

    data = model.get(model_obj.id)

    assert data.cost_usd == 10

    assert model_obj.cost_usd == 10

    # assert model.index.select().first().cost == 10.0  # is always in usd
    # TODO:*1 need to get the sqlite index to work again

    print("TEST FOR MODELS DONE, but is still minimal")

    return "OK"

from Jumpscale import j


def main(self):
    """
    to run:

    kosmos 'j.data.bcdb.test(name="models")'

    work with toml files and see if models get generated properly

    """
    mpath = self._dirpath + "/tests/models"
    assert j.sal.fs.exists(mpath)

    # make sure we remove the maybe already previously generated model file
    for item in j.sal.fs.listFilesInDir(mpath, filter="*.py"):
        j.sal.fs.remove(item)

    bcdb, _ = self._load_test_model()

    bcdb.models_add(mpath)

    model = bcdb.model_get_from_url("jumpscale.bcdb.test.house")

    model_obj = model.new()
    model_obj.cost = "10 USD"
    model_obj.save()

    data = model.get(model_obj.id)

    assert data.cost_usd == 10

    assert model_obj.cost_usd == 10

    # assert model.index.select().first().cost == 10.0  # is always in usd
    # TODO:*1 need to get the sqlite index to work again

    print("TEST FOR MODELS DONE, but is still minimal")

    return "OK"
to run:      kosmos 'j.data.bcdb.test(name="models")'      work with toml files and see if models get generated properly # make sure we remove the maybe already previously generated model file # assert model.index.select().first().cost == 10.0  # is always in usd # TODO:*1 need to get the sqlite index to work again