Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_constructor(self):
"""
Test constructing a SecurityDocument
"""
sdoc = SecurityDocument(self.db)
self.assertIsInstance(sdoc, SecurityDocument)
self.assertEqual(sdoc.r_session, self.db.r_session)
def test_get_security_document(self):
"""
Test retrieving the database security document
"""
self.load_security_document_data()
sdoc = self.db.get_security_document()
self.assertIsInstance(sdoc, SecurityDocument)
self.assertDictEqual(sdoc, self.sdoc)
def test_save(self):
"""
Test that the security document is updated correctly
"""
sdoc = SecurityDocument(self.db)
sdoc.fetch()
sdoc.update(self.mod_sdoc)
sdoc.save()
mod_sdoc = SecurityDocument(self.db)
mod_sdoc.fetch()
self.assertDictEqual(mod_sdoc, self.mod_sdoc)
def test_json(self):
"""
Test the security document dictionary renders as a JSON string
"""
sdoc = SecurityDocument(self.db)
sdoc.fetch()
sdoc_as_json_string = sdoc.json()
self.assertIsInstance(sdoc_as_json_string, str)
sdoc_as_a_dict = json.loads(sdoc_as_json_string)
self.assertDictEqual(sdoc_as_a_dict, sdoc)
def test_context_manager(self):
"""
Test that the context SecurityDocument context manager enter and exit
routines work as expected.
"""
with SecurityDocument(self.db) as sdoc:
self.assertDictEqual(sdoc, self.sdoc)
sdoc.update(self.mod_sdoc)
mod_sdoc = SecurityDocument(self.db)
mod_sdoc.fetch()
self.assertDictEqual(mod_sdoc, self.mod_sdoc)
def test_context_manager(self):
"""
Test that the context SecurityDocument context manager enter and exit
routines work as expected.
"""
with SecurityDocument(self.db) as sdoc:
self.assertDictEqual(sdoc, self.sdoc)
sdoc.update(self.mod_sdoc)
mod_sdoc = SecurityDocument(self.db)
mod_sdoc.fetch()
self.assertDictEqual(mod_sdoc, self.mod_sdoc)
def test_constructor(self):
"""
Test constructing a SecurityDocument
"""
sdoc = SecurityDocument(self.db)
self.assertIsInstance(sdoc, SecurityDocument)
self.assertEqual(sdoc.r_session, self.db.r_session)
def test_document_url(self):
"""
Test that the document url is populated correctly
"""
sdoc = SecurityDocument(self.db)
self.assertEqual(
sdoc.document_url,
'/'.join([self.db.database_url, '_security'])
)
def test_save(self):
"""
Test that the security document is updated correctly
"""
sdoc = SecurityDocument(self.db)
sdoc.fetch()
sdoc.update(self.mod_sdoc)
sdoc.save()
mod_sdoc = SecurityDocument(self.db)
mod_sdoc.fetch()
self.assertDictEqual(mod_sdoc, self.mod_sdoc)