Esempio n. 1
0
    def test_table_definition(self):
        """ Tests that creating a table with capitalized column names succeedso """
        create_table(LowercaseKeyModel)
        create_table(CapitalizedKeyModel)

        delete_table(LowercaseKeyModel)
        delete_table(CapitalizedKeyModel)
Esempio n. 2
0
    def test_multiple_deletes_dont_fail(self):
        """

        """
        create_table(TestModel)

        delete_table(TestModel)
        delete_table(TestModel)
Esempio n. 3
0
def cassandra_reset():
    from feedly.feeds.cassandra import CassandraFeed
    from feedly.feeds.aggregated_feed.cassandra import CassandraAggregatedFeed
    from cqlengine.management import create_table
    aggregated_timeline = CassandraAggregatedFeed.get_timeline_storage()
    timeline = CassandraFeed.get_timeline_storage()
    create_table(aggregated_timeline.model)
    create_table(timeline.model)
Esempio n. 4
0
    def test_reserved_cql_words_can_be_used_as_column_names(self):
        """
        """
        create_table(ReservedWordModel)

        model1 = ReservedWordModel.create(token='1', insert=5)

        model2 = ReservedWordModel.filter(token='1')

        assert len(model2) == 1
        assert model1.token == model2[0].token
        assert model1.insert == model2[0].insert
    def setUpClass(cls):
        super(TestDateTimeQueries, cls).setUpClass()
        create_table(DateTimeQueryTestModel)

        cls.base_date = datetime.now() - timedelta(days=10)
        for x in range(7):
            for y in range(10):
                DateTimeQueryTestModel.create(
                    user=x,
                    day=(cls.base_date+timedelta(days=y)),
                    data=str(uuid4())
                )
    def test_concrete_class_table_creation_cycle(self):
        """ Tests that models with inherited abstract classes can be created, and have io performed """
        from cqlengine.management import create_table, delete_table
        create_table(ConcreteModelWithCol)

        w1 = ConcreteModelWithCol.create(pkey=5, data=6)
        w2 = ConcreteModelWithCol.create(pkey=6, data=7)

        r1 = ConcreteModelWithCol.get(pkey=5)
        r2 = ConcreteModelWithCol.get(pkey=6)

        assert w1.pkey == r1.pkey
        assert w1.data == r1.data
        assert w2.pkey == r2.pkey
        assert w2.data == r2.data

        delete_table(ConcreteModelWithCol)
Esempio n. 7
0
    def setUpClass(cls):
        super(BaseColumnIOTest, cls).setUpClass()

        #if the test column hasn't been defined, bail out
        if not cls.column: return

        # create a table with the given column
        class IOTestModel(Model):
            table_name = cls.column.db_type + "_io_test_model_{}".format(uuid4().hex[:8])
            pkey = cls.column(primary_key=True)
            data = cls.column()
        cls._generated_model = IOTestModel
        create_table(cls._generated_model)

        #tupleify the tested values
        if not isinstance(cls.pkey_val, tuple):
            cls.pkey_val = cls.pkey_val,
        if not isinstance(cls.data_val, tuple):
            cls.data_val = cls.data_val,
Esempio n. 8
0
def cassandra_setup():
    from cqlengine.management import create_table, create_keyspace
    aggregated_timeline = AggregatedFeed.get_timeline_storage()
    timeline = FashiolistaFeed.get_timeline_storage()
    user_timeline = UserFeed.get_timeline_storage()
    create_keyspace('test')
    create_table(aggregated_timeline.model)
    create_table(timeline.model)
    create_table(user_timeline.model)
Esempio n. 9
0
    def setUpClass(cls):
        super(BaseQuerySetUsage, cls).setUpClass()
        delete_table(TestModel)
        delete_table(IndexedTestModel)
        create_table(TestModel)
        create_table(IndexedTestModel)

        TestModel.objects.create(test_id=0, attempt_id=0, description='try1', expected_result=5, test_result=30)
        TestModel.objects.create(test_id=0, attempt_id=1, description='try2', expected_result=10, test_result=30)
        TestModel.objects.create(test_id=0, attempt_id=2, description='try3', expected_result=15, test_result=30)
        TestModel.objects.create(test_id=0, attempt_id=3, description='try4', expected_result=20, test_result=25)

        TestModel.objects.create(test_id=1, attempt_id=0, description='try5', expected_result=5, test_result=25)
        TestModel.objects.create(test_id=1, attempt_id=1, description='try6', expected_result=10, test_result=25)
        TestModel.objects.create(test_id=1, attempt_id=2, description='try7', expected_result=15, test_result=25)
        TestModel.objects.create(test_id=1, attempt_id=3, description='try8', expected_result=20, test_result=20)

        TestModel.objects.create(test_id=2, attempt_id=0, description='try9', expected_result=50, test_result=40)
        TestModel.objects.create(test_id=2, attempt_id=1, description='try10', expected_result=60, test_result=40)
        TestModel.objects.create(test_id=2, attempt_id=2, description='try11', expected_result=70, test_result=45)
        TestModel.objects.create(test_id=2, attempt_id=3, description='try12', expected_result=75, test_result=45)

        IndexedTestModel.objects.create(test_id=0, attempt_id=0, description='try1', expected_result=5, test_result=30)
        IndexedTestModel.objects.create(test_id=1, attempt_id=1, description='try2', expected_result=10, test_result=30)
        IndexedTestModel.objects.create(test_id=2, attempt_id=2, description='try3', expected_result=15, test_result=30)
        IndexedTestModel.objects.create(test_id=3, attempt_id=3, description='try4', expected_result=20, test_result=25)

        IndexedTestModel.objects.create(test_id=4, attempt_id=0, description='try5', expected_result=5, test_result=25)
        IndexedTestModel.objects.create(test_id=5, attempt_id=1, description='try6', expected_result=10, test_result=25)
        IndexedTestModel.objects.create(test_id=6, attempt_id=2, description='try7', expected_result=15, test_result=25)
        IndexedTestModel.objects.create(test_id=7, attempt_id=3, description='try8', expected_result=20, test_result=20)

        IndexedTestModel.objects.create(test_id=8, attempt_id=0, description='try9', expected_result=50, test_result=40)
        IndexedTestModel.objects.create(test_id=9, attempt_id=1, description='try10', expected_result=60, test_result=40)
        IndexedTestModel.objects.create(test_id=10, attempt_id=2, description='try11', expected_result=70, test_result=45)
        IndexedTestModel.objects.create(test_id=11, attempt_id=3, description='try12', expected_result=75, test_result=45)
Esempio n. 10
0
    def test_add_column(self):
        create_table(FirstModel)
        fields = get_fields(FirstModel)

        # this should contain the second key
        self.assertEqual(len(fields), 2)
        # get schema
        create_table(SecondModel)

        fields = get_fields(FirstModel)
        self.assertEqual(len(fields), 3)

        create_table(ThirdModel)
        fields = get_fields(FirstModel)
        self.assertEqual(len(fields), 4)

        create_table(FourthModel)
        fields = get_fields(FirstModel)
        self.assertEqual(len(fields), 4)
Esempio n. 11
0
 def setUpClass(cls):
     super(TestListColumn, cls).setUpClass()
     delete_table(TestListModel)
     create_table(TestListModel)
 def test_attempting_to_create_abstract_table_fails(self):
     """ Attempting to create a table from an abstract model should fail """
     from cqlengine.management import create_table
     with self.assertRaises(CQLEngineException):
         create_table(AbstractModelWithFullCols)
 def setUpClass(cls):
     super(TestClusteringOrder, cls).setUpClass()
     create_table(TestModel)
Esempio n. 14
0
 def setUpClass(cls):
     super(TestDeleting, cls).setUpClass()
     delete_table(TestMultiKeyModel)
     create_table(TestMultiKeyModel)
Esempio n. 15
0
 def setUpClass(cls):
     super(TestDate, cls).setUpClass()
     create_table(cls.DateTest)
Esempio n. 16
0
 def test_a_sensical_error_is_raised_if_you_try_to_create_a_table_twice(self):
     """
     """
     create_table(TestModel)
     create_table(TestModel)
Esempio n. 17
0
 def test_exception_isnt_raised_if_an_index_is_defined_more_than_once(self):
     create_table(IndexDefinitionModel)
     create_table(IndexDefinitionModel)
Esempio n. 18
0
 def setUpClass(cls):
     super(TestDecimal, cls).setUpClass()
     create_table(cls.DecimalTest)
Esempio n. 19
0
 def setUpClass(cls):
     super(TestQuerying, cls).setUpClass()
     delete_table(TestQueryModel)
     create_table(TestQueryModel)
Esempio n. 20
0
 def setUpClass(cls):
     super(TestCanUpdate, cls).setUpClass()
     delete_table(TestModel)
     create_table(TestModel)
Esempio n. 21
0
def cassandra_cql_reset():
    from feedly.feeds.cassandraCQL import CassandraCQLFeed
    from cqlengine.management import create_table

    timeline = CassandraCQLFeed.get_timeline_storage()
    create_table(timeline.model)
Esempio n. 22
0
 def setUpClass(cls):
     super(BatchQueryTests, cls).setUpClass()
     delete_table(TestMultiKeyModel)
     create_table(TestMultiKeyModel)
Esempio n. 23
0
 def setUpClass(cls):
     super(TestTimeUUID, cls).setUpClass()
     create_table(cls.TimeUUIDTest)
 def setUpClass(cls):
     super(TestEqualityOperators, cls).setUpClass()
     create_table(TestModel)
Esempio n. 25
0
 def setUpClass(cls):
     super(TestModelIO, cls).setUpClass()
     create_table(TestModel)
Esempio n. 26
0
 def setUpClass(cls):
     super(TestMinMaxTimeUUIDFunctions, cls).setUpClass()
     create_table(TimeUUIDQueryModel)
Esempio n. 27
0
 def setUpClass(cls):
     super(TestVarInt, cls).setUpClass()
     create_table(cls.VarIntTest)