Ejemplo n.º 1
0
class ColumnsTests(TableTests):
    def setUp(self):
        self.reference = Columns('table', ['first_column', 'second_column'],
                                 lambda column: column.upper())

    def test_references_column(self):
        self.assertIs(
            self.reference.references_column('other', 'first_column'), False)
        self.assertIs(
            self.reference.references_column('table', 'third_column'), False)
        self.assertIs(
            self.reference.references_column('table', 'first_column'), True)

    def test_rename_column_references(self):
        self.reference.rename_column_references('other', 'first_column',
                                                'third_column')
        self.assertIs(
            self.reference.references_column('table', 'first_column'), True)
        self.assertIs(
            self.reference.references_column('table', 'third_column'), False)
        self.assertIs(
            self.reference.references_column('other', 'third_column'), False)
        self.reference.rename_column_references('table', 'third_column',
                                                'first_column')
        self.assertIs(
            self.reference.references_column('table', 'first_column'), True)
        self.assertIs(
            self.reference.references_column('table', 'third_column'), False)
        self.reference.rename_column_references('table', 'first_column',
                                                'third_column')
        self.assertIs(
            self.reference.references_column('table', 'first_column'), False)
        self.assertIs(
            self.reference.references_column('table', 'third_column'), True)

    def test_repr(self):
        self.assertEqual(repr(self.reference),
                         "<Columns 'FIRST_COLUMN, SECOND_COLUMN'>")

    def test_str(self):
        self.assertEqual(str(self.reference), 'FIRST_COLUMN, SECOND_COLUMN')
Ejemplo n.º 2
0
class ColumnsTests(TableTests):
    def setUp(self):
        self.reference = Columns("table", ["first_column", "second_column"],
                                 lambda column: column.upper())

    def test_references_column(self):
        self.assertIs(
            self.reference.references_column("other", "first_column"), False)
        self.assertIs(
            self.reference.references_column("table", "third_column"), False)
        self.assertIs(
            self.reference.references_column("table", "first_column"), True)

    def test_rename_column_references(self):
        self.reference.rename_column_references("other", "first_column",
                                                "third_column")
        self.assertIs(
            self.reference.references_column("table", "first_column"), True)
        self.assertIs(
            self.reference.references_column("table", "third_column"), False)
        self.assertIs(
            self.reference.references_column("other", "third_column"), False)
        self.reference.rename_column_references("table", "third_column",
                                                "first_column")
        self.assertIs(
            self.reference.references_column("table", "first_column"), True)
        self.assertIs(
            self.reference.references_column("table", "third_column"), False)
        self.reference.rename_column_references("table", "first_column",
                                                "third_column")
        self.assertIs(
            self.reference.references_column("table", "first_column"), False)
        self.assertIs(
            self.reference.references_column("table", "third_column"), True)

    def test_repr(self):
        self.assertEqual(repr(self.reference),
                         "<Columns 'FIRST_COLUMN, SECOND_COLUMN'>")

    def test_str(self):
        self.assertEqual(str(self.reference), "FIRST_COLUMN, SECOND_COLUMN")
Ejemplo n.º 3
0
class ColumnsTests(TableTests):
    def setUp(self):
        self.reference = Columns(
            'table', ['first_column', 'second_column'], lambda column: column.upper()
        )

    def test_references_column(self):
        self.assertIs(self.reference.references_column('other', 'first_column'), False)
        self.assertIs(self.reference.references_column('table', 'third_column'), False)
        self.assertIs(self.reference.references_column('table', 'first_column'), True)

    def test_rename_column_references(self):
        self.reference.rename_column_references('other', 'first_column', 'third_column')
        self.assertIs(self.reference.references_column('table', 'first_column'), True)
        self.assertIs(self.reference.references_column('table', 'third_column'), False)
        self.assertIs(self.reference.references_column('other', 'third_column'), False)
        self.reference.rename_column_references('table', 'third_column', 'first_column')
        self.assertIs(self.reference.references_column('table', 'first_column'), True)
        self.assertIs(self.reference.references_column('table', 'third_column'), False)
        self.reference.rename_column_references('table', 'first_column', 'third_column')
        self.assertIs(self.reference.references_column('table', 'first_column'), False)
        self.assertIs(self.reference.references_column('table', 'third_column'), True)

    def test_repr(self):
        self.assertEqual(repr(self.reference), "<Columns 'FIRST_COLUMN, SECOND_COLUMN'>")

    def test_str(self):
        self.assertEqual(str(self.reference), 'FIRST_COLUMN, SECOND_COLUMN')