File: test_sync.py

package info (click to toggle)
cloudprint 0.14-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 512 kB
  • sloc: python: 1,128; sh: 48; makefile: 16
file content (50 lines) | stat: -rw-r--r-- 1,197 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import mock

from cloudprint import cloudprint


def test_get_printer_info(tmpdir):
    ppd_path = tmpdir.join('ppd')
    ppd_path.write('this is a ppd')

    cups = mock.Mock(name='cups')
    cups.getPPD.return_value = str(ppd_path)
    cups.getPrinterAttributes.return_value = {
        'printer-info': mock.sentinel.desc
    }

    ppd, description = cloudprint.get_printer_info(cups, 'foo')

    assert ppd == 'this is a ppd'
    assert description == mock.sentinel.desc

    cups.getPPD.assert_called_with('foo')
    cups.getPrinterAttributes.assert_called_with('foo')


def test_sync_add_printer(cups, cpp):
    cups.test_add_printer('new')

    cloudprint.sync_printers(cups, cpp)

    cpp.add_printer.assert_called_with('new', mock.ANY, mock.ANY)


def test_sync_rm_printer(cups, cpp):
    old_printer = cpp.test_add_printer('old')

    cloudprint.sync_printers(cups, cpp)

    old_printer.delete.assert_called_with()


def test_sync_update_printer(cups, cpp):
    cups.test_add_printer('old')
    old_printer = cpp.test_add_printer('old')

    cloudprint.sync_printers(cups, cpp)

    old_printer.update.assert_called_with(
        old_printer.description,
        old_printer.ppd,
    )