コード例 #1
0
def test_is_url_unique_false(url):
    assert db.insert_group(helpers.random_module_code(), url, 0, 0)
    assert validate.is_url_unique(url) is False
コード例 #2
0
def test_update_user_saved_state_not_exist(user_row):
    new_saved_state = helpers.random_module_code()
    assert db.update_user_saved_state(user_row[0], new_saved_state) is None
コード例 #3
0
import os, os.path, sqlite3, sys
import pytest

sys.path.append(os.path.join(os.getcwd()))
from scripts.migrate import main as migrate
import helpers

sys.path.append(os.path.join(os.getcwd(), 'phonebook'))
import db, validate
from datatypes import User, Group

seeds_module_codes = tuple(helpers.random_module_code() for _ in range(10))
seeds_valid_codes = ('GER1000', 'CS1101S', 'UWC2101D', 'CM1401', 'USS2105',
                     'LSM2241', 'LSM2232', 'UQF2101I', 'CS1231', 'MA1101R')
seeds_invalid_codes = ('A123456', '', '1000GER', '999', 'COMPBIO', 'USS',
                       'ST2131/MA2216', '7', '0.667', '*')
seeds_urls = tuple(helpers.random_url() for _ in range(10))
seeds_invalid_urls = ('google.com', 'https://regex101.com', 'localhost',
                      '127.0.0.1', '8.8.8.8',
                      'https://gist.github.com/nifl/1178878', 'example.com',
                      'sourceacademy.nus.edu.sg', 'ningyuan.io',
                      'https://coursemology.org/courses/1345/')


def setup_function(function):
    os.environ['DB_NAME'] = 'test.db'
    migrate()


def teardown_function(function):
    os.remove('test.db')
コード例 #4
0
def test_update_user_saved_state(user_row):
    new_saved_state = helpers.random_module_code()
    assert db.insert_user(*user_row) == True
    assert db.update_user_saved_state(user_row[0], new_saved_state) == True
    assert db.get_user(user_row[0]).saved_state == new_saved_state