Esempio n. 1
0
 def setUp(self):
     TestCase.setUp(self)
     TestHelper.setUp(self)
     self.threadpool = FakeThreadPool()
     self.transaction = self.mocker.mock()
     self.transactor = Transactor(self.threadpool, self.transaction)
     self.function = self.mocker.mock()
    def setUp(self):
        super().setUp()
        one_entity_file_path = (
            'tests/samples/proposed/raw_field_selection_one_entity.yaml')
        self.highest_score_argument = TestHelper.prepare_dimension_argument(
            dimension=RawFieldSelection,
            proposed_path=one_entity_file_path,
            solution_path=one_entity_file_path)

        empty_file_path = 'tests/samples/empty.yaml'
        self.none_score_argument = TestHelper.prepare_dimension_argument(
            dimension=RawFieldSelection,
            proposed_path=empty_file_path,
            solution_path=empty_file_path)

        self.lowest_score_argument = TestHelper.prepare_dimension_argument(
            dimension=RawFieldSelection,
            proposed_path=empty_file_path,
            solution_path=one_entity_file_path)

        two_entities_file_path = (
            'tests/samples/proposed/raw_field_selection_two_entities.yaml')
        self.middling_score_argument = TestHelper.prepare_dimension_argument(
            dimension=RawFieldSelection,
            proposed_path=one_entity_file_path,
            solution_path=two_entities_file_path)
Esempio n. 3
0
 def setUp(self):
     TestHelper.setUp(self)
     class Class(object):
         __storm_table__ = "table"
         prop1 = Property("column1", primary=True)
     self.Class = Class
     self.ClassAlias = ClassAlias(self.Class, "alias")
Esempio n. 4
0
  def setUp(self):
    super().setUp()
    one_entity_file_path = (
        'tests/samples/proposed/unit_mapping_one_entity.yaml')
    self.highest_score_argument = TestHelper.prepare_dimension_argument(
        dimension=UnitMapping,
        proposed_path=one_entity_file_path,
        solution_path=one_entity_file_path)

    empty_file_path = 'tests/samples/empty.yaml'
    self.none_score_argument = TestHelper.prepare_dimension_argument(
        dimension=UnitMapping,
        proposed_path=empty_file_path,
        solution_path=empty_file_path)

    self.lowest_score_argument = TestHelper.prepare_dimension_argument(
        dimension=UnitMapping,
        proposed_path=empty_file_path,
        solution_path=one_entity_file_path)

    two_entities_file_path = (
        'tests/samples/proposed/unit_mapping_two_entities.yaml')
    self.middling_score_argument = TestHelper.prepare_dimension_argument(
        dimension=UnitMapping,
        proposed_path=one_entity_file_path,
        solution_path=two_entities_file_path)
Esempio n. 5
0
 def setUp(self):
     TestHelper.setUp(self)
     self.executed = []
     self.database = Database()
     self.raw_connection = RawConnection(self.executed)
     self.database.raw_connect = lambda: self.raw_connection
     self.connection = Connection(self.database)
Esempio n. 6
0
 def setUp(self):
     TestCase.setUp(self)
     TestHelper.setUp(self)
     self.threadpool = FakeThreadPool()
     self.transaction = self.mocker.mock()
     self.transactor = Transactor(self.threadpool, self.transaction)
     self.function = self.mocker.mock()
Esempio n. 7
0
 def setUp(self):
     TestHelper.setUp(self)
     self.executed = []
     self.database = Database()
     self.raw_connection = RawConnection(self.executed)
     self.database.raw_connect = lambda: self.raw_connection
     self.connection = Connection(self.database)
Esempio n. 8
0
 def setUp(self):
     TestHelper.setUp(self)
     class Class(object):
         __storm_table__ = "table"
         prop1 = Property("column1", primary=True)
         prop2 = Property("column2")
     self.Class = Class
     self.cls_info = get_cls_info(Class)
Esempio n. 9
0
def run(data):
    helper = TestHelper(data)

    if not helper.is_empty():
        print('Data is not empty.')
        return TestHelper.FAIL_CODE

    return TestHelper.SUCCESS_CODE
Esempio n. 10
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "table"
            prop1 = Property("column1", primary=True)

        self.Class = Class
        self.ClassAlias = ClassAlias(self.Class, "alias")
Esempio n. 11
0
 def setUp(self):
     TestHelper.setUp(self)
     self.db_module = new.module("db_module")
     self.uri = None
     def create_from_uri(uri):
         self.uri = uri
         return "RESULT"
     self.db_module.create_from_uri = create_from_uri
     sys.modules["storm.databases.db_module"] = self.db_module
Esempio n. 12
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "table"
            prop1 = Property("column1", primary=True)
            prop2 = Property("column2")

        self.Class = Class
        self.cls_info = get_cls_info(Class)
Esempio n. 13
0
def run(data):
    helper = TestHelper(data)

    try:
        helper.is_io_correct(5, 1, 1, 0)
    except TestHelperException as e:
        print(e.msg)
        return TestHelper.FAIL_CODE

    return TestHelper.SUCCESS_CODE
Esempio n. 14
0
 def setUp(self):
     TestHelper.setUp(self)
     class Class(object):
         __storm_table__ = "mytable"
         prop1 = Custom("column1", primary=True)
         prop2 = Custom()
         prop3 = Custom("column3", default=50, allow_none=False)
     class SubClass(Class):
         __storm_table__ = "mysubtable"
     self.Class = Class
     self.SubClass = SubClass
Esempio n. 15
0
 def setUp(self):
     TestHelper.setUp(self)
     class Class(object):
         __storm_table__ = "mytable"
         prop1 = Custom("column1", primary=True)
         prop2 = Custom()
         prop3 = Custom("column3", default=50, allow_none=False)
     class SubClass(Class):
         __storm_table__ = "mysubtable"
     self.Class = Class
     self.SubClass = SubClass
Esempio n. 16
0
 def setUp(self):
     TestHelper.setUp(self)
     class Class(object):
         __storm_table__ = "table"
         prop1 = Property("column1", primary=True)
         prop2 = Property("column2")
     self.Class = Class
     self.obj = Class()
     self.obj_info = get_obj_info(self.obj)
     self.cls_info = get_cls_info(Class)
     self.variable1 = self.obj_info.variables[Class.prop1]
     self.variable2 = self.obj_info.variables[Class.prop2]
Esempio n. 17
0
    def setUp(self):
        TestHelper.setUp(self)

        # Allow classes with the same name in different tests to resolve
        # property path strings properly.
        SQLObjectBase._storm_property_registry.clear()

        self.store = Store(create_database("sqlite:"))

        class SQLObject(SQLObjectBase):
            @staticmethod
            def _get_store():
                return self.store

        self.SQLObject = SQLObject

        self.store.execute("CREATE TABLE person "
                           "(id INTEGER PRIMARY KEY, name TEXT, age INTEGER,"
                           " ts TIMESTAMP, delta INTERVAL,"
                           " address_id INTEGER)")
        self.store.execute("INSERT INTO person VALUES "
                           "(1, 'John Joe', 20, '2007-02-05 19:53:15',"
                           " '1 day, 12:34:56', 1)")
        self.store.execute("INSERT INTO person VALUES "
                           "(2, 'John Doe', 20, '2007-02-05 20:53:15',"
                           " '42 days 12:34:56.78', 2)")

        self.store.execute("CREATE TABLE address "
                           "(id INTEGER PRIMARY KEY, city TEXT)")
        self.store.execute("INSERT INTO address VALUES (1, 'Curitiba')")
        self.store.execute("INSERT INTO address VALUES (2, 'Sao Carlos')")

        self.store.execute("CREATE TABLE phone "
                           "(id INTEGER PRIMARY KEY, person_id INTEGER,"
                           "number TEXT)")
        self.store.execute("INSERT INTO phone VALUES (1, 2, '1234-5678')")
        self.store.execute("INSERT INTO phone VALUES (2, 1, '8765-4321')")
        self.store.execute("INSERT INTO phone VALUES (3, 2, '8765-5678')")

        self.store.execute("CREATE TABLE person_phone "
                           "(id INTEGER PRIMARY KEY, person_id INTEGER, "
                           "phone_id INTEGER)")
        self.store.execute("INSERT INTO person_phone VALUES (1, 2, 1)")
        self.store.execute("INSERT INTO person_phone VALUES (2, 2, 2)")
        self.store.execute("INSERT INTO person_phone VALUES (3, 1, 1)")

        class Person(self.SQLObject):
            _defaultOrder = "-Person.name"
            name = StringCol()
            age = IntCol()
            ts = UtcDateTimeCol()

        self.Person = Person
Esempio n. 18
0
    def setUp(self):
        TestHelper.setUp(self)

        # Allow classes with the same name in different tests to resolve
        # property path strings properly.
        SQLObjectBase._storm_property_registry.clear()

        self.store = Store(create_database("sqlite:"))
        class SQLObject(SQLObjectBase):
            @staticmethod
            def _get_store():
                return self.store

        self.SQLObject = SQLObject

        self.store.execute("CREATE TABLE person "
                           "(id INTEGER PRIMARY KEY, name TEXT, age INTEGER,"
                           " ts TIMESTAMP, delta INTERVAL,"
                           " address_id INTEGER)")
        self.store.execute("INSERT INTO person VALUES "
                           "(1, 'John Joe', 20, '2007-02-05 19:53:15',"
                           " '1 day, 12:34:56', 1)")
        self.store.execute("INSERT INTO person VALUES "
                           "(2, 'John Doe', 20, '2007-02-05 20:53:15',"
                           " '42 days 12:34:56.78', 2)")

        self.store.execute("CREATE TABLE address "
                           "(id INTEGER PRIMARY KEY, city TEXT)")
        self.store.execute("INSERT INTO address VALUES (1, 'Curitiba')")
        self.store.execute("INSERT INTO address VALUES (2, 'Sao Carlos')")

        self.store.execute("CREATE TABLE phone "
                           "(id INTEGER PRIMARY KEY, person_id INTEGER,"
                           "number TEXT)")
        self.store.execute("INSERT INTO phone VALUES (1, 2, '1234-5678')")
        self.store.execute("INSERT INTO phone VALUES (2, 1, '8765-4321')")
        self.store.execute("INSERT INTO phone VALUES (3, 2, '8765-5678')")

        self.store.execute("CREATE TABLE person_phone "
                           "(id INTEGER PRIMARY KEY, person_id INTEGER, "
                           "phone_id INTEGER)")
        self.store.execute("INSERT INTO person_phone VALUES (1, 2, 1)")
        self.store.execute("INSERT INTO person_phone VALUES (2, 2, 2)")
        self.store.execute("INSERT INTO person_phone VALUES (3, 1, 1)")

        class Person(self.SQLObject):
            _defaultOrder = "-Person.name"
            name = StringCol()
            age = IntCol()
            ts = UtcDateTimeCol()

        self.Person = Person
Esempio n. 19
0
def run(data):
    helper = TestHelper(data)

    try:
        value = 1
        for t in range(21):
            helper.is_io_correct(t, 0, value, 0)
            if value: value = 0
            else: value = 1
    except TestHelperException as e:
        print(e.msg)
        return TestHelper.FAIL_CODE
    return TestHelper.SUCCESS_CODE
Esempio n. 20
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "table"
            prop1 = Property("column1", primary=True)
            prop2 = Property("column2")

        self.Class = Class
        self.obj = Class()
        self.obj_info = get_obj_info(self.obj)
        self.cls_info = get_cls_info(Class)
        self.variable1 = self.obj_info.variables[Class.prop1]
        self.variable2 = self.obj_info.variables[Class.prop2]
Esempio n. 21
0
 def test_crazy_metaclass(self):
     """We don't want metaclasses playing around when we build an alias."""
     TestHelper.setUp(self)
     class MetaClass(type):
         def __new__(meta_cls, name, bases, dict):
             cls = type.__new__(meta_cls, name, bases, dict)
             cls.__storm_table__ = "HAH! GOTCH YA!"
             return cls
     class Class(object):
         __metaclass__ = MetaClass
         __storm_table__ = "table"
         prop1 = Property("column1", primary=True)
     Alias = ClassAlias(Class, "USE_THIS")
     self.assertEquals(Alias.__storm_table__, "USE_THIS")
Esempio n. 22
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "mytable"
            prop1 = Property("column1", primary=True)
            prop2 = Property()

        class SubClass(Class):
            __storm_table__ = "mysubtable"

        self.Class = Class
        self.SubClass = SubClass
        self.AnotherClass = type("Class", (Class, ), {})

        self.registry = PropertyRegistry()
Esempio n. 23
0
    def test_crazy_metaclass(self):
        """We don't want metaclasses playing around when we build an alias."""
        TestHelper.setUp(self)

        class MetaClass(type):
            def __new__(meta_cls, name, bases, dict):
                cls = type.__new__(meta_cls, name, bases, dict)
                cls.__storm_table__ = "HAH! GOTCH YA!"
                return cls

        class Class(with_metaclass(MetaClass, object)):
            __storm_table__ = "table"
            prop1 = Property("column1", primary=True)

        Alias = ClassAlias(Class, "USE_THIS")
        self.assertEquals(Alias.__storm_table__, "USE_THIS")
Esempio n. 24
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "mytable"
            prop1 = Property("column1", primary=True)
            prop2 = Property()

        class SubClass(Class):
            __storm_table__ = "mysubtable"

        self.Class = Class
        self.SubClass = SubClass
        self.AnotherClass = type("Class", (Class,), {})

        self.registry = PropertyRegistry()
Esempio n. 25
0
    def setUp(self):
        TestHelper.setUp(self)

        class Class(object):
            __storm_table__ = "mytable"
            prop1 = Custom("column1", primary=True, size=11, unsigned=True)
            prop2 = Custom()
            prop3 = Custom("column3", default=50, allow_none=False)
            prop4 = Custom(
                "column4", index=True, unique=True, auto_increment=True,
                array={'other_value': 1}
            )

        class SubClass(Class):
            __storm_table__ = "mysubtable"
        self.Class = Class
        self.SubClass = SubClass
    def setUp(self):
        super().setUp()
        featureful_file_path = (
            'tests/samples/proposed/entity_connection_identification.yaml')
        self.highest_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityConnectionIdentification,
            proposed_path=featureful_file_path,
            solution_path=featureful_file_path)

        empty_file_path = 'tests/samples/empty.yaml'
        self.none_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityConnectionIdentification,
            proposed_path=empty_file_path,
            solution_path=empty_file_path)

        no_contains_file_path = 'tests/samples/proposed/entity_connection_identification_no_contains.yaml'  # pylint: disable=line-too-long

        self.middling_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityConnectionIdentification,
            proposed_path=no_contains_file_path,
            solution_path=featureful_file_path)
Esempio n. 27
0
    def setUp(self):
        super().setUp()
        featureful_file_path = (
            'tests/samples/proposed/entity_type_identification_virtual.yaml')
        self.highest_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityTypeIdentification,
            proposed_path=featureful_file_path,
            solution_path=featureful_file_path)

        empty_file_path = 'tests/samples/empty.yaml'
        self.none_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityTypeIdentification,
            proposed_path=empty_file_path,
            solution_path=empty_file_path)

        reporting_entity_file_path = (
            'tests/samples/proposed/entity_type_identification_reporting.yaml')
        self.middling_score_argument = TestHelper.prepare_dimension_argument(
            dimension=EntityTypeIdentification,
            proposed_path=reporting_entity_file_path,
            solution_path=featureful_file_path)
Esempio n. 28
0
    def setUp(self):
        TestHelper.setUp(self)

        class Base(object):
            __metaclass__ = PropertyPublisherMeta

        class Class(Base):
            __storm_table__ = "mytable"
            prop1 = Property("column1", primary=True)
            prop2 = Property()

        class SubClass(Class):
            __storm_table__ = "mysubtable"

        self.Class = Class
        self.SubClass = SubClass

        class Class(Class):
            __module__ += ".foo"
            prop3 = Property("column3")

        self.AnotherClass = Class

        self.registry = Base._storm_property_registry
Esempio n. 29
0
    def setUp(self):
        TestHelper.setUp(self)

        class Base(object):
            __metaclass__ = PropertyPublisherMeta

        class Class(Base):
            __storm_table__ = "mytable"
            prop1 = Property("column1", primary=True)
            prop2 = Property()

        class SubClass(Class):
            __storm_table__ = "mysubtable"

        self.Class = Class
        self.SubClass = SubClass

        class Class(Class):
            __module__ += ".foo"
            prop3 = Property("column3")

        self.AnotherClass = Class

        self.registry = Base._storm_property_registry
Esempio n. 30
0
 def tearDown(self):
     del sys.modules["storm.databases.db_module"]
     TestHelper.tearDown(self)
Esempio n. 31
0
 def setUp(self):
     TestHelper.setUp(self)
     self.executed = []
     self.raw_cursor = RawCursor(executed=self.executed)
     self.result = Result(FakeConnection(), self.raw_cursor)
Esempio n. 32
0
 def tearDown(self):
     TestHelper.tearDown(self)
     remove_all_tracers()
Esempio n. 33
0
 def setUp(self):
     TestHelper.setUp(self)
     self.database = Database()
Esempio n. 34
0
 def tearDown(self):
     TestHelper.tearDown(self)
     EmptyResultSetTest.tearDown(self)
Esempio n. 35
0
 def tearDown(self):
     TestHelper.tearDown(self)
     EmptyResultSetTest.tearDown(self)
Esempio n. 36
0
 def setUpClass(cls):
     cls.helper = TestHelper()
     cls.balena = cls.helper.balena
Esempio n. 37
0
 def tearDown(self):
     if 'factory' in storm.database._database_schemes:
         del storm.database._database_schemes['factory']
     TestHelper.tearDown(self)
Esempio n. 38
0
 def tearDown(self):
     del sys.modules["storm.databases.db_module"]
     TestHelper.tearDown(self)
Esempio n. 39
0
 def setUp(self):
     TestHelper.setUp(self)
     self.executed = []
     self.raw_cursor = RawCursor(executed=self.executed)
     self.result = Result(FakeConnection(), self.raw_cursor)
Esempio n. 40
0
 def tearDown(self):
     TestHelper.tearDown(self)
     remove_all_tracers()
Esempio n. 41
0
 def setUp(self):
     TestHelper.setUp(self)
     return DeferredStoreTest.setUp(self)
Esempio n. 42
0
 def tearDown(self):
     if 'factory' in storm.database._database_schemes:
         del storm.database._database_schemes['factory']
     TestHelper.tearDown(self)
Esempio n. 43
0
 def setUp(self):
     TestHelper.setUp(self)
     self.event = EventSystem(marker)
Esempio n. 44
0
 def tearDown(self):
     TestHelper.tearDown(self)
     StoreTest.tearDown(self)
Esempio n. 45
0
 def setUp(self):
     TestHelper.setUp(self)
     EmptyResultSetTest.setUp(self)
Esempio n. 46
0
 def setUp(self):
     TestHelper.setUp(self)
     self.database = Database()
Esempio n. 47
0
 def setUp(self):
     TestHelper.setUp(self)
     EmptyResultSetTest.setUp(self)
Esempio n. 48
0
 def setUp(self):
     TestHelper.setUp(self)
     StoreTest.setUp(self)
Esempio n. 49
0
 def setUp(self):
     TestHelper.setUp(self)
     return StorePoolTest.setUp(self)
Esempio n. 50
0
 def cb(passthrough):
     TestHelper.tearDown(self)
     return passthrough