Beispiel #1
0
    def test_update_heads_file_two_heads(self):
        with mock.patch("alembic.script.ScriptDirectory.from_config") as fc:
            heads = ("b", "a")
            fc.return_value.get_heads.return_value = heads
            with mock.patch("six.moves.builtins.open") as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_heads_file(mock.sentinel.config)
                mock_open.return_value.write.assert_called_once_with("\n".join(sorted(heads)))
Beispiel #2
0
    def test_update_heads_file_success(self):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            heads = ('a', 'b')
            fc.return_value.get_heads.return_value = heads
            with mock.patch('six.moves.builtins.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_heads_file(mock.sentinel.config)
                mock_open.return_value.write.assert_called_once_with(
                    '\n'.join(heads))
Beispiel #3
0
    def test_update_heads_file_two_heads(self):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            heads = ('b', 'a')
            fc.return_value.get_heads.return_value = heads
            with mock.patch('six.moves.builtins.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_heads_file(self.configs[0])
                mock_open.return_value.write.assert_called_once_with(
                    '\n'.join(sorted(heads)))
    def test_update_heads_file_success(self, *os_mocks):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            heads = ('a', 'b')
            fc.return_value.get_heads.return_value = heads
            with mock.patch('six.moves.builtins.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_heads_file(self.configs[0])
                mock_open.return_value.write.assert_called_once_with(
                    '\n'.join(heads))

                old_head_file = cli._get_head_file_path(self.configs[0])
                for mock_ in os_mocks:
                    mock_.assert_called_with(old_head_file)
Beispiel #5
0
    def test_update_heads_file_success(self, *os_mocks):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            heads = ('a', 'b')
            fc.return_value.get_heads.return_value = heads
            with mock.patch('six.moves.builtins.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_heads_file(self.configs[0])
                mock_open.return_value.write.assert_called_once_with(
                    '\n'.join(heads))

                old_head_file = cli._get_head_file_path(self.configs[0])
                for mock_ in os_mocks:
                    mock_.assert_called_with(old_head_file)