<commit_before>#!/usr/bin/python2.4
#
# Copyright (c) 2005-2008 rPath, Inc.
#
# All Rights Reserved
#
import testsuite
testsuite.setup()

import os
import re
import shutil
import copy

import mint_rephelp
import fixtures
from mint.web import project
from mint.web import site
from mint import database
from mint.web.webhandler import HttpNotFound, HttpMoved
from mint import jobstatus
from mint import buildtypes
from mint import userlevels
from mint import users
from mint import helperfuncs

from mint_rephelp import MINT_PROJECT_DOMAIN

from repostest import testRecipe
from conary import versions
from conary.lib import util

testDirRecipe = """
class TestCase(PackageRecipe):
    name = "testcase"
    version = "1.0"

    def setup(r):
        r.Create("/temp/foo")
        r.MakeDirs("/temp/directory", mode = 0775)
"""

class rogueReq(object):
    def __init__(self):
        self.err_headers_out = {}
        self.headers_out = {}
        self.uri = ''

class session(dict):
    def save(self):
        pass

class WebProjectBaseTest(mint_rephelp.WebRepositoryHelper):
    def _setupProjectHandler(self):
        client, userId = self.quickMintUser('testuser', 'testpass')
        projectId = self.newProject(client, 'Foo', 'testproject',
                MINT_PROJECT_DOMAIN)
        projectHandler = project.ProjectHandler()
        projectHandler.projectId = projectId
        projectHandler.project = client.getProject(projectId)
        projectHandler.userLevel = userlevels.OWNER
        projectHandler.client = client
        projectHandler.session = session()
        projectHandler.cfg = self.mintCfg
        projectHandler.req = rogueReq()
        projectHandler.auth = users.Authorization(\
            token = ('test<PASSWORD>', 'testpass'))
        projectHandler.isWriter = True
        projectHandler.isOwner = True
        projectHandler.SITE = self.mintCfg.siteHost + self.mintCfg.basePath
        projectHandler.basePath = self.mintCfg.basePath
        projectHandler.searchType = None
        projectHandler.searchTerms = ''
        projectHandler.inlineMime = None
        projectHandler.infoMsg = None
        projectHandler.errorMsgList = []
        projectHandler.currentVersion = projectHandler.client.addProductVersion(projectHandler.projectId, self.mintCfg.namespace, "version1", "Fluff description")
        projectHandler._setCurrentProductVersion(projectHandler.currentVersion)
        projectHandler.versions = projectHandler.client.getProductVersionListForProduct(projectHandler.projectId)

        return projectHandler

    def _setupSiteHandler(self):
        client, userId = self.quickMintUser('testuser', 'testpass')
        siteHandler = site.SiteHandler()
        siteHandler.client = client
        siteHandler.cfg = self.mintCfg
        siteHandler.req = rogueReq()
        siteHandler.req.hostname = self.mintCfg.siteHost.split(':')[0]
        siteHandler.auth = users.Authorization(\
            token = ('<PASSWORD>', '<PASSWORD>'))
        siteHandler.auth.authorized = True
        siteHandler.SITE = self.mintCfg.siteHost + self.mintCfg.basePath
        siteHandler.basePath = self.mintCfg.basePath
        siteHandler.searchType = None
        siteHandler.searchTerms = ''
        siteHandler.inlineMime = None
        siteHandler.infoMsg = None
        siteHandler.errorMsgList = []
        siteHandler.session = session()<commit_msg>Fix testcase to work with 15de2647ca82 (RBL-3158)<commit_after>#!/usr/bin/python2.4
#
# Copyright (c) 2005-2008 rPath, Inc.
#
# All Rights Reserved
#
import testsuite
testsuite.setup()

import os
import re
import shutil
import copy

import mint_rephelp
import fixtures
from mint.web import project
from mint.web import site
from mint import database
from mint.web.webhandler import HttpNotFound, HttpMoved
from mint import jobstatus
from mint import buildtypes
from mint import userlevels
from mint import users
from mint import helperfuncs

from mint_rephelp import MINT_PROJECT_DOMAIN

from repostest import testRecipe
from conary import versions
from conary.lib import util

testDirRecipe = """
class TestCase(PackageRecipe):
    name = "testcase"
    version = "1.0"

    def setup(r):
        r.Create("/temp/foo")
        r.MakeDirs("/temp/directory", mode = 0775)
"""

class rogueReq(object):
    def __init__(self):
        self.err_headers_out = {}
        self.headers_out = {}
        self.uri = ''

class session(dict):
    def save(self):
        pass

class WebProjectBaseTest(mint_rephelp.WebRepositoryHelper):
    def _setupProjectHandler(self):
        client, userId = self.quickMintUser('testuser', 'testpass')
        projectId = self.newProject(client, 'Foo', 'testproject',
                MINT_PROJECT_DOMAIN)
        projectHandler = project.ProjectHandler()
        projectHandler.projectId = projectId
        projectHandler.project = client.getProject(projectId)
        projectHandler.userLevel = userlevels.OWNER
        projectHandler.client = client
        projectHandler.session = session()
        projectHandler.cfg = self.mintCfg
        projectHandler.req = rogueReq()
        projectHandler.auth = users.Authorization(\
            token = ('<PASSWORD>', '<PASSWORD>'))
        projectHandler.isWriter = True
        projectHandler.isOwner = True
        projectHandler.SITE = self.mintCfg.siteHost + self.mintCfg.basePath
        projectHandler.basePath = self.mintCfg.basePath
        projectHandler.searchType = None
        projectHandler.searchTerms = ''
        projectHandler.inlineMime = None
        projectHandler.infoMsg = None
        projectHandler.errorMsgList = []
        projectHandler.currentVersion = projectHandler.client.addProductVersion(projectHandler.projectId, self.mintCfg.namespace, "version1", "Fluff description")
        projectHandler._setCurrentProductVersion(projectHandler.currentVersion)
        projectHandler.versions = projectHandler.client.getProductVersionListForProduct(projectHandler.projectId)
        projectHandler.latestRssNews = {}

        return projectHandler

    def _setupSiteHandler(self):
        client, userId = self.quickMintUser('testuser', 'testpass')
        siteHandler = site.SiteHandler()
        siteHandler.client = client
        siteHandler.cfg = self.mintCfg
        siteHandler.req = rogueReq()
        siteHandler.req.hostname = self.mintCfg.siteHost.split(':')[0]
        siteHandler.auth = users.Authorization(\
            token = ('testuser', '<PASSWORD>'))
        siteHandler.auth.authorized = True
        siteHandler.SITE = self.mintCfg.siteHost + self.mintCfg.basePath
        siteHandler.basePath = self.mintCfg.basePath
        siteHandler.searchType = None
        siteHandler.searchTerms = ''
        siteHandler.inlineMime = None
        siteHandler.infoMsg = None
        siteHandler.errorMsgList = []
        siteHandler.session = session()
        siteHandler.latestRssNews = {}
{'fraction_non_alphanumeric': 0.08977519941986947, 'fraction_numerical': 0.0069615663524292964, 'mean_word_length': 3.18955042527339, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6474917', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1895, 'n_words': 411}