# external imports
import unittest
# local imports
import nautilus
import nautilus.models as models

class TestUtil(unittest.TestCase):
    """
        This test suite checks the behavior of the various mixins that come
        with nautilus.
    """

    def setUp(self):
        # point the database to a in-memory sqlite database
        nautilus.database.init_db('sqlite:///test.db')


    def test_password_field(self):
        # create a table with a password
        class TestPassword(models.BaseModel):
            password = nautilus.auth.PasswordField()

        # create the table
        TestPassword.create_table(True)

        # create an instance of the table with a password
        record = TestPassword(password="foo")
        # save the record to the database
        record.save()

        # retireve the record
        password = TestPassword.get(TestPassword.id == record.id).password
        # make sure there is a hash assocaited with the password
        assert hasattr(password, 'hash') , (
            "Retrieved record's password did not come with a hash"
        )
        # make sure that hash hide the password
        assert password.hash != 'foo' , (
            "Retrieved record's password is in plain sight!"
        )
        # make sure we can check for password equality
        assert password == 'foo', (
            'Password could not checked for equality.'
        )

        # remove the table from the database
        TestPassword.drop_table()

d54c45d4cc3d9a9294e1a33b6006c6a8ca422b72
<mask token>


class TestUtil(unittest.TestCase):
    <mask token>

    def setUp(self):
        nautilus.database.init_db('sqlite:///test.db')
    <mask token>

<mask token>


class TestUtil(unittest.TestCase):
    <mask token>

    def setUp(self):
        nautilus.database.init_db('sqlite:///test.db')

    def test_password_field(self):


        class TestPassword(models.BaseModel):
            password = nautilus.auth.PasswordField()
        TestPassword.create_table(True)
        record = TestPassword(password='foo')
        record.save()
        password = TestPassword.get(TestPassword.id == record.id).password
        assert hasattr(password, 'hash'
            ), "Retrieved record's password did not come with a hash"
        assert password.hash != 'foo', "Retrieved record's password is in plain sight!"
        assert password == 'foo', 'Password could not checked for equality.'
        TestPassword.drop_table()

<mask token>


class TestUtil(unittest.TestCase):
    """
        This test suite checks the behavior of the various mixins that come
        with nautilus.
    """

    def setUp(self):
        nautilus.database.init_db('sqlite:///test.db')

    def test_password_field(self):


        class TestPassword(models.BaseModel):
            password = nautilus.auth.PasswordField()
        TestPassword.create_table(True)
        record = TestPassword(password='foo')
        record.save()
        password = TestPassword.get(TestPassword.id == record.id).password
        assert hasattr(password, 'hash'
            ), "Retrieved record's password did not come with a hash"
        assert password.hash != 'foo', "Retrieved record's password is in plain sight!"
        assert password == 'foo', 'Password could not checked for equality.'
        TestPassword.drop_table()

import unittest
import nautilus
import nautilus.models as models


class TestUtil(unittest.TestCase):
    """
        This test suite checks the behavior of the various mixins that come
        with nautilus.
    """

    def setUp(self):
        nautilus.database.init_db('sqlite:///test.db')

    def test_password_field(self):


        class TestPassword(models.BaseModel):
            password = nautilus.auth.PasswordField()
        TestPassword.create_table(True)
        record = TestPassword(password='foo')
        record.save()
        password = TestPassword.get(TestPassword.id == record.id).password
        assert hasattr(password, 'hash'
            ), "Retrieved record's password did not come with a hash"
        assert password.hash != 'foo', "Retrieved record's password is in plain sight!"
        assert password == 'foo', 'Password could not checked for equality.'
        TestPassword.drop_table()

# external imports
import unittest
# local imports
import nautilus
import nautilus.models as models

class TestUtil(unittest.TestCase):
    """
        This test suite checks the behavior of the various mixins that come
        with nautilus.
    """

    def setUp(self):
        # point the database to a in-memory sqlite database
        nautilus.database.init_db('sqlite:///test.db')


    def test_password_field(self):
        # create a table with a password
        class TestPassword(models.BaseModel):
            password = nautilus.auth.PasswordField()

        # create the table
        TestPassword.create_table(True)

        # create an instance of the table with a password
        record = TestPassword(password="foo")
        # save the record to the database
        record.save()

        # retireve the record
        password = TestPassword.get(TestPassword.id == record.id).password
        # make sure there is a hash assocaited with the password
        assert hasattr(password, 'hash') , (
            "Retrieved record's password did not come with a hash"
        )
        # make sure that hash hide the password
        assert password.hash != 'foo' , (
            "Retrieved record's password is in plain sight!"
        )
        # make sure we can check for password equality
        assert password == 'foo', (
            'Password could not checked for equality.'
        )

        # remove the table from the database
        TestPassword.drop_table()
