-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_reposettings.py
45 lines (38 loc) · 1.08 KB
/
test_reposettings.py
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
import unittest
from unittest.mock import MagicMock
import reposettings as rs
class TestRepoSettings(unittest.TestCase):
def test_validate(self):
self.assertFalse(rs.RepoSettings._validate({}))
self.assertFalse(rs.RepoSettings._validate({
"repos": None
}))
self.assertFalse(rs.RepoSettings._validate({
"repos": True
}))
self.assertFalse(rs.RepoSettings._validate({
"repos": {}
}))
self.assertTrue(rs.RepoSettings._validate({
"repos": {"a": {}}
}))
def test_apply(self):
ghmock = MagicMock()
r = rs.RepoSettings(ghmock)
r.apply({
"repos": {
"test": {}
}
})
ghmock.get_repo.assert_called_with("test")
settermock = MagicMock()
settermock.name.return_value = "mock"
r.use(settermock)
r.apply({
"repos": {
"test": {}
}
})
settermock.set.assert_called_once()
if __name__ == '__main__':
unittest.main()