Ejemplo n.º 1
0
class AccountAliasAccessorTest(MasuTestCase):
    """Test Cases for the AuthDBAccessor object."""
    def setUp(self):
        """Setup test cases."""
        self.account_id = '123456789'
        self.schema = 'acct10001'
        self.accessor = AccountAliasAccessor(self.account_id, self.schema)
        self.accessor.commit()

    def tearDown(self):
        """Tear down test case."""
        self.accessor._session.delete(self.accessor._obj)
        self.accessor.commit()
        self.accessor.close_session()

    def test_initializer(self):
        """Test Initializer."""
        self.assertIsNotNone(self.accessor._session)
        self.assertTrue(self.accessor.does_db_entry_exist())

        obj = self.accessor._get_db_obj_query().first()
        self.assertEqual(obj.account_id, self.account_id)
        self.assertEqual(obj.account_alias, self.account_id)

    def test_set_account_alias(self):
        """test alias setter."""
        alias_name = 'test-alias'
        self.accessor.set_account_alias(alias_name)
        self.accessor.commit()
        obj = self.accessor._get_db_obj_query().first()
        self.assertEqual(obj.account_id, self.account_id)
        self.assertEqual(obj.account_alias, alias_name)
Ejemplo n.º 2
0
 def tearDown(self):
     """Teardown test case."""
     db_access = AccountAliasAccessor(self.account_id, 'acct10001')
     db_access._get_db_obj_query().delete()
     db_access.get_session().commit()
     db_access.close_session()