def test_delete_tag(forge_client: Callable[[str], FlaskClient]): t = Tag.add(random_tag_str(), engine.Tag.Category.NORMAL_PROBLEM) user = utils.user.Factory.teacher() client = forge_client(user.username) rv = client.delete( '/tag', json={ 'tags': [str(t.pk)], 'category': engine.Tag.Category.NORMAL_PROBLEM }, ) assert rv.status_code == 200, rv.data assert not Tag.is_tag(t.pk, engine.Tag.Category.NORMAL_PROBLEM)
def test_tag_add(): assert len(Tag.engine.objects(value='tag')) == 0 t = Tag.add('tag', engine.Tag.Category.NORMAL_PROBLEM) assert Tag.is_tag('tag', engine.Tag.Category.NORMAL_PROBLEM) assert len(Tag.engine.objects(value='tag')) == 1, Tag.engine( value='tag', categories=engine.Tag.Category.NORMAL_PROBLEM).categories