Пример #1
0
 def test_update_head_file_success(self):
     head = ['b']
     mock_open = self.useFixture(
         tools.OpenFixture(cli._get_head_file_path(
             self.configs[0]))).mock_open
     with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
         fc.return_value.get_heads.return_value = head
         cli.update_head_file(self.configs[0])
         mock_open.return_value.write.assert_called_with('\n'.join(head))
Пример #2
0
 def test_update_head_file_success(self):
     head = ['b']
     mock_open = self.useFixture(
                 tools.OpenFixture(cli._get_head_file_path(
                     self.configs[0]))).mock_open
     with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
         fc.return_value.get_heads.return_value = head
         cli.update_head_file(self.configs[0])
         mock_open.return_value.write.assert_called_with(
             '\n'.join(head))
Пример #3
0
    def test_update_head_file_success(self):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            fc.return_value.get_heads.return_value = ['a']
            fc.return_value.get_current_head.return_value = 'a'
            with mock.patch('__builtin__.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_head_file(mock.sentinel.config)
                mock_open.return_value.write.assert_called_once_with('a')
            fc.assert_called_once_with(mock.sentinel.config)
Пример #4
0
    def test_update_head_file_success(self):
        with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            fc.return_value.get_heads.return_value = ['a']
            fc.return_value.get_current_head.return_value = 'a'
            with mock.patch('__builtin__.open') as mock_open:
                mock_open.return_value.__enter__ = lambda s: s
                mock_open.return_value.__exit__ = mock.Mock()

                cli.update_head_file(mock.sentinel.config)
                mock_open.return_value.write.assert_called_once_with('a')
            fc.assert_called_once_with(mock.sentinel.config)
Пример #5
0
    def test_update_head_file_success(self):
        with mock.patch("alembic.script.ScriptDirectory.from_config") as fc:
            fc.return_value.get_heads.return_value = ["a"]
            fc.return_value.get_current_head.return_value = "a"
            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_head_file(mock.sentinel.config)
                mock_open.return_value.write.assert_called_once_with("a")
            fc.assert_called_once_with(mock.sentinel.config)