How to use the cloudant.security_document.SecurityDocument function in cloudant

To help you get started, we’ve selected a few cloudant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / database_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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'])
        )
github cloudant / python-cloudant / tests / unit / security_document_tests.py View on Github external
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)