コード例 #1
0
    def test_configurationReader(self):
        # instantiating config file reader
        configFilesPath = settings.PICBADGEPATH + '/configFiles/'
        configFile = "testConfigFile.txt"
        agreeFile = "testAgreement.txt"

        reader = configReader(configFilesPath, configFile)
        appConfig = reader.getConfigHandler()
        book1Config = appConfig.book1
        book1Choices = reader.getChoices(book1Config)
        book1Name = book1Config.name

        # this part tests including another config file in main config
        book2Config = appConfig.otherBook.book2
        book2Choices = reader.getChoices(book2Config)
        book2Name = book2Config.name

        # this part tests reading a text block from another file
        agreeText = reader.getAgreement(agreeFile)
        # this part tests including choices from another file.
        booksList = appConfig.booknames

        self.failUnlessEqual(book1Name, "My book 1")
        self.failUnlessEqual(book1Choices, [('2009', '2009'),
                                            ('2007', '2007')])

        self.failUnlessEqual(book2Name, "My book 2")
        self.failUnlessEqual(book2Choices, [('2019', '2019'),
                                            ('2017', '2017')])

        self.failUnlessEqual(agreeText.strip(), "My test agreement.")
        """ write code for template testing """
コード例 #2
0
ファイル: tests.py プロジェクト: aromasnar/libre-PIC-badger
 def test_configurationReader(self):
     # instantiating config file reader
     configFilesPath = settings.PICBADGEPATH + '/configFiles/'
     configFile = "testConfigFile.txt"  
     agreeFile = "testAgreement.txt"      
     
     reader = configReader(configFilesPath, configFile)
     appConfig = reader.getConfigHandler()
     book1Config = appConfig.book1
     book1Choices = reader.getChoices(book1Config)
     book1Name = book1Config.name
     
     # this part tests including another config file in main config
     book2Config = appConfig.otherBook.book2
     book2Choices = reader.getChoices(book2Config)
     book2Name = book2Config.name
     
     # this part tests reading a text block from another file
     agreeText = reader.getAgreement(agreeFile)
     # this part tests including choices from another file.
     booksList = appConfig.booknames
     
     self.failUnlessEqual(book1Name, "My book 1")
     self.failUnlessEqual(book1Choices, [('2009', '2009'), ('2007', '2007')])
     
     self.failUnlessEqual(book2Name, "My book 2")
     self.failUnlessEqual(book2Choices, [('2019', '2019'), ('2017', '2017')])
     
     self.failUnlessEqual(agreeText.strip(), "My test agreement.")       
     
     """ write code for template testing """ 
コード例 #3
0
ファイル: models.py プロジェクト: aromasnar/libre-PIC-badger
from django.db import models
from django import forms
from polarCommonProj.picBadge.scripts.utilityFunctions import Utilities
import config
import os.path
from django.conf import settings
from symbol import except_clause
from polarCommonProj.picBadge.configurationReader import configReader 

# instantiating config file reader
configFilesPath = settings.PICBADGEPATH + '/configFiles/'
configFile = "picBadgeAppConfiguration.cfg"
CC_Zero_AgreementFile = 'ccLicAgreement.txt'
CC_By_AgreementFile = 'ccByLicAgreement.txt'

reader = configReader(configFilesPath, configFile)
appConfig = reader.getConfigHandler()
	
# Badging API requires output type for both licenses (pic_cc_by & pic_cc_zero) and have following two values.
outputTypeConfig = appConfig.picBadgerAppOutputType
outputTypeChoices = reader.getChoices(outputTypeConfig)
 
# Label for license Agreement ... NOTE:  DONT CHANGE
licenseAgreementLabel = "Agreement"

# Form specification for the PIC CC Zero form w.r.t PIC CC Zero specification provided by pic api.
class cc0UserInfoForm(forms.Form):
    #global reader, CC_Zero_AgreementFile	
    titleConfig = appConfig.picZeroForm.pic_cc_zero.title
    title = forms.CharField(required=False, label=titleConfig.label, help_text=titleConfig.helpText)
	
コード例 #4
0
# This file contains all information about ALL the PIC CC Licenses.
import sys
import re
from xml.dom.minidom import Document
from django.conf import settings
from polarCommonProj.picBadge.scripts.utilityFunctions import Callable
from polarCommonProj.picBadge.configurationReader import configReader

# I don't necessarily like using the Web App's config, but I don't really
# want to duplicate it either, so I'll just do this for now
configFilesPath = settings.PICBADGEPATH + '/configFiles/'
configFile = "picBadgeAppConfiguration.cfg"
CC_Zero_AgreementFile = 'ccLicAgreement.txt'
CC_By_AgreementFile = 'ccByLicAgreement.txt'

reader = configReader(configFilesPath, configFile)
appConfig = reader.getConfigHandler()

class picLicenses:
	
	# the api offers two differnt output types
	licenseOutput = {"html": "License HTML ONLY", "xml":"XML having License HTML and RDF"}
	# pic cc license classes
	picLicenseClasses = {'pic_cc_zero':"PIC CC ZERO Waiver", 'pic_cc_by':"PIC CC BY License"}
	# pic_cc_zero license specifications... fields, labels and descriptions
	picCCZeroFields = {'title': ("Title of Work", "The title of the work"),
						'attribution_url':("Your URL", "The URL of the work"),
						'territory':("Territory", "The country code"),
						'creator':("Publisher", "The name of the creator of the work"),
						'outputType':("License Output format", "The format of the output")}