Example #1
0
    def test_utils_markup_dumps(self):
        assert markup.dumps('123') == "'123'"

        expected = \
            "[\n    '123',\n    1,\n    1.1,\n    {\n        foo: ()\n    }\n]"
        expected = expected.replace(' ', '')
        assert markup.dumps(['123', 1, 1.1, {
            'foo': ()
        }]).replace(' ', '') == expected
Example #2
0
    def test_utils_markup_overflow_deep_1(self):
        obj = a = []
        for _ in range(200):
            a.append([])
            a = a[0]

        result = markup.dumps(obj).replace(' ', '').replace('\n', '')

        # current limit is 100, so 2 chars per list - 200 + some space reserved
        # for the OverflowBarier markup element
        #
        assert len(result) < 220
Example #3
0
    def test_utils_markup_overflow_wide(self):
        obj3 = []
        for _ in range(10):
            obj2 = []
            for _ in range(10):
                obj1 = []
                for _ in range(10):
                    obj = []
                    for _ in range(20):
                        obj.append(list(1 for _ in range(10)))
                    obj1.append(obj)
                obj2.append(obj1)
            obj3.append(obj2)

        result = markup.dumps(obj3).replace(' ', '').replace('\n', '')
        assert len(result) < 13000
Example #4
0
    def _assert_migration_consistency(self, schema_text):

        migration_text = f'''
            CREATE MIGRATION m TO {{
                {schema_text}
            }};
        '''

        migration_ql = edgeql.parse_block(migration_text)

        migration_cmd = s_ddl.cmd_from_ddl(
            migration_ql[0],
            schema=self.schema,
            modaliases={None: 'default'},
        )

        migration_cmd = s_ddl.compile_migration(
            migration_cmd,
            self.std_schema,
            self.schema,
        )

        context = s_delta.CommandContext()
        schema, migration = migration_cmd.apply(self.schema, context)

        ddl_plan = s_delta.DeltaRoot(canonical=True)
        ddl_plan.update(migration.get_commands(schema))

        baseline_schema, _ = ddl_plan.apply(schema, context)

        ddl_text = s_ddl.ddl_text_from_delta(schema, migration)

        try:
            test_schema = self.run_ddl(schema, ddl_text)
        except errors.EdgeDBError as e:
            self.fail(markup.dumps(e))

        diff = s_ddl.delta_schemas(baseline_schema, test_schema)

        if list(diff.get_subcommands()):
            self.fail(
                f'unexpected difference in schema produced by\n'
                f'COMMIT MIGRATION and DDL obtained from GET MIGRATION:\n'
                f'{markup.dumps(diff)}\n'
                f'DDL text was:\n{ddl_text}')
Example #5
0
 def test_utils_markup_dump_ordereddict(self):
     obj = collections.OrderedDict([[1, 2], [2, 3], [3, 4], [5, 6]])
     result = ''.join(markup.dumps(obj).split())
     assert result == '{1:2,2:3,3:4,5:6}'