File: test_helper.py

package info (click to toggle)
python-ipmi 0.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 884 kB
  • sloc: python: 9,547; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from mock import MagicMock, call
from nose.tools import eq_

from pyipmi.helper import (clear_repository_helper, ERASURE_COMPLETED,
                           ERASURE_IN_PROGRESS, INITIATE_ERASE,
                           GET_ERASE_STATUS)


def test_clear_repository_helper():
    reserve_fn = MagicMock()
    reserve_fn.return_value = (0x1234)

    clear_fn = MagicMock()
    clear_fn.side_effect = [
        ERASURE_COMPLETED,
        ERASURE_IN_PROGRESS,
        ERASURE_COMPLETED,
    ]

    clear_repository_helper(reserve_fn, clear_fn)

    clear_calls = [
        call(INITIATE_ERASE, 0x1234),
        call(GET_ERASE_STATUS, 0x1234),
        call(GET_ERASE_STATUS, 0x1234),
    ]
    clear_fn.assert_has_calls(clear_calls)
    eq_(clear_fn.call_count, 3)