Ejemplo n.º 1
0
 def test_to_basic(self):
     cfg = StubConfig()
     field = SecureField(method='test')
     assert field.to_basic(cfg, 'hello') == {
         'method': 'test',
         'ciphertext': base64.b64encode(b'ciphertext').decode()
     }
     cfg._keyfile.__enter__.assert_called_once_with()
     cfg._keyfile.encrypt.assert_called_once_with('hello', method='test')
     cfg._keyfile.__exit__.assert_called_once_with(None, None, None)
Ejemplo n.º 2
0
 def test_to_basic_none(self):
     field = SecureField()
     assert field.to_basic(StubConfig(), None) is None
Ejemplo n.º 3
0
 def test_to_basic_empty_string(self):
     field = SecureField()
     assert field.to_basic(None, "") is None
Ejemplo n.º 4
0
 def test_to_basic_none(self):
     field = SecureField()
     assert field.to_basic(None, None) is None