MCPcopy
hub / github.com/celery/celery / test_init

Method test_init

t/unit/security/test_certificate.py:84–109  ·  view source on GitHub ↗
(self, Certificate, glob, isdir)

Source from the content-addressed store, hash-verified

82 @patch('glob.glob')
83 @patch('celery.security.certificate.Certificate')
84 def test_init(self, Certificate, glob, isdir):
85 cert = Certificate.return_value = Mock()
86 cert.has_expired.return_value = False
87 isdir.return_value = True
88 glob.return_value = ['foo.cert']
89 with conftest.open():
90 cert.get_id.return_value = 1
91
92 path = os.path.join('var', 'certs')
93 x = FSCertStore(path)
94 assert 1 in x._certs
95 glob.assert_called_with(os.path.join(path, '*'))
96
97 # they both end up with the same id
98 glob.return_value = ['foo.cert', 'bar.cert']
99 with pytest.raises(SecurityError):
100 x = FSCertStore(path)
101 glob.return_value = ['foo.cert']
102
103 cert.has_expired.return_value = True
104 with pytest.raises(SecurityError):
105 x = FSCertStore(path)
106
107 isdir.return_value = False
108 with pytest.raises(SecurityError):
109 x = FSCertStore(path)

Callers

nothing calls this directly

Calls 4

FSCertStoreClass · 0.90
openMethod · 0.45
joinMethod · 0.45
raisesMethod · 0.45

Tested by

no test coverage detected