File: utils.py

package info (click to toggle)
annexremote 1.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 1,637; sh: 24; makefile: 10
file content (134 lines) | stat: -rw-r--r-- 2,503 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import unittest
from unittest import mock
import io

import os, sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

import annexremote


class GitAnnexTestCase(unittest.TestCase):
    def setUp(self):
        super().setUp()

        self.output = io.StringIO()
        self.input = io.StringIO()

        self.annex = annexremote.Master(self.output)
        self.remote = mock.MagicMock(wraps=DummyRemote(self.annex))

        self.annex.LinkRemote(self.remote)


class MinimalTestCase(unittest.TestCase):
    def setUp(self):
        super().setUp()

        self.output = io.StringIO()
        self.input = io.StringIO()

        self.annex = annexremote.Master(self.output)
        self.remote = MinimalRemote(self.annex)

        self.annex.LinkRemote(self.remote)


def first_buffer_line(buf):
    return buffer_lines(buf)[0]


def second_buffer_line(buf):
    return buffer_lines(buf)[1]


def last_buffer_line(buf):
    return buffer_lines(buf)[-1]


def buffer_lines(buf):
    current_position = buf.tell()
    buf.seek(0)
    lines = list()
    for line in buf:
        lines.append(line.rstrip("\n"))
    buf.seek(current_position)
    return lines


class MinimalRemote(annexremote.SpecialRemote):
    def initremote(self):
        pass

    def prepare(self):
        pass

    def transfer_store(self, key, file_):
        pass

    def transfer_retrieve(self, key, file_):
        pass

    def checkpresent(self, key):
        pass

    def remove(self, key):
        pass


class DummyRemote(annexremote.ExportRemote):
    def initremote(self):
        pass

    def prepare(self):
        pass

    def transfer_store(self, key, file_):
        pass

    def transfer_retrieve(self, key, file_):
        pass

    def checkpresent(self, key):
        pass

    def remove(self, key):
        pass

    def getcost(self):
        pass

    def getavailability(self):
        pass

    def claimurl(self, url):
        pass

    def checkurl(self, url):
        pass

    def whereis(self, whereis):
        pass

    def error(self, msg):
        pass

    # Export methods
    def transferexport_store(self, key, file_, name):
        pass

    def transferexport_retrieve(self, key, file_, name):
        pass

    def checkpresentexport(self, key, name):
        pass

    def removeexport(self, key, name):
        pass

    def removeexportdirectory(self, directory):
        pass

    def renameexport(self, key, name, new_name):
        pass