Ejemplo n.º 1
0
def _insert_favorite():
    """Insert starting default entries into the Favorite table.

    Args:
        None

    Returns:
        None

    """
    # Insert into Favorite
    if favorite.idx_exists(1) is False:
        favorite.insert_row(
            DbRowFavorite(idx_chart=1, idx_user=1, order=0, enabled=0))
Ejemplo n.º 2
0
    def test_exists(self):
        """Testing method or function named "exists"."""
        # Add user entry to database
        uname = data.hashstring(str(random()))
        passwrd = data.hashstring(str(random()))
        salt_ = data.hashstring(str(random()))
        f_name = data.hashstring(str(random()))
        l_name = data.hashstring(str(random()))
        user.insert_row(
            DbRowUser(
                username=uname,
                password=passwrd,
                first_name=f_name,
                role=0,
                password_expired=1,
                last_name=l_name,
                enabled=0,
            ))
        # Make sure user entry exists
        idx_user = user.exists(uname)

        # Add chart entry to database
        chart_name = data.hashstring(str(random()))
        chart_checksum = data.hashstring(str(random()))
        chart.insert_row(
            DbRowChart(name=chart_name, checksum=chart_checksum, enabled=0))

        # Make sure chart entry exists
        idx_chart = chart.exists(chart_checksum)

        # Make sure favorite does not exist
        result = favorite.exists(idx_chart, idx_user)
        self.assertFalse(bool(result))

        # Add favorite to database
        favorite.insert_row(
            DbRowFavorite(idx_chart=idx_chart,
                          idx_user=idx_user,
                          order=0,
                          enabled=0))

        # Make sure favorite exists
        result = favorite.exists(idx_chart, idx_user)
        self.assertTrue(bool(result))
Ejemplo n.º 3
0
    def test_idx_exists(self):
        """Testing method or function named "idx_exists"."""
        # Add user entry to database
        uname = data.hashstring(str(random()))
        passwrd = data.hashstring(str(random()))
        f_name = data.hashstring(str(random()))
        l_name = data.hashstring(str(random()))
        user.insert_row(
            DbRowUser(username=uname,
                      password=passwrd,
                      first_name=f_name,
                      last_name=l_name,
                      user_type=1,
                      change_password=1,
                      enabled=0))

        # Make sure user entry exists
        idx_user = user.exists(uname)
        self.assertTrue(bool(idx_user))

        # Add chart entry to database
        chart_name = data.hashstring(str(random()))
        chart_checksum = data.hashstring(str(random()))
        chart.insert_row(
            DbRowChart(name=chart_name, checksum=chart_checksum, enabled=0))

        # Make sure chart entry exists
        idx_chart = chart.exists(chart_checksum)
        self.assertTrue(bool(idx_chart))

        # Add favorite to database
        favorite.insert_row(
            DbRowFavorite(idx_chart=idx_chart,
                          idx_user=idx_user,
                          order=0,
                          enabled=0))

        # Make sure the favorite exists
        idx_favorite = favorite.exists(idx_chart, idx_user)

        # Verify that the index exists
        result = favorite.idx_exists(idx_favorite)
        self.assertTrue(result)