Exemple #1
0
def test_bulk_load_bottle_types_4():
    db._reset_db()

    data = "a,b"
    fp = StringIO(data)                 # make this look like a file handle
    n = load_bulk_data.load_bottle_types(fp)

    assert n == 0, n
def test_bulk_load_bottle_types_1():
    db._reset_db()

    data = "Johnnie Walker,Black Label,blended scotch"
    fp = StringIO(data)                 # make this look like a file handle
    n = load_bulk_data.load_bottle_types(fp)

    assert db._check_bottle_type_exists('Johnnie Walker', 'Black Label')
    assert n == 1, n
Exemple #3
0
def comment_test():
	db._reset_db()																										#1
	
	mfg = 'Johnnie Walker'																								#2
	name = 'Black Label'
	typ = 'Blended Scotch'
	amt = '1000ml'

	st_typ = "#this comment is not suitable for children\n" + mfg + "," + name + "," + typ + "\n#nor is this one."		#3
	st_amt = "#this comment is not suitable for children\n" + mfg + "," + name + "\n#nor is this one."

	fp_typ = StringIO(st_typ)																							#4
	fp_amt = StringIO(st_amt)

	load_bulk_data.load_bottle_types(fp_typ)																			#5
	assert db._check_bottle_type_exists(mfg, name) == True

	load_bulk_data.load_inventory(fp_amt)																				#6
	assert db.check_inventory(mfg, name) == False
Exemple #4
0
def wspace_test():
	db._reset_db()														#1

	mfg = 'Johnnie Walker'												#2
	name = 'Black Label'
	typ = 'Blended Scotch'
	amt = '1000ml'

	st_typ = "\n \n \n" + mfg + "," + name + "," + typ + "\n\n\n"		#3
	st_amt = "\n \n \n" + mfg + "," + name + "\n\n\n"

	fp_typ = StringIO(st_typ)											#4
	fp_amt = StringIO(st_amt)
	
	load_bulk_data.load_bottle_types(fp_typ)							#5
	assert db._check_bottle_type_exists(mfg, name) == True

	load_bulk_data.load_inventory(fp_amt)								#6
	assert db.check_inventory(mfg, name) == False
Exemple #5
0
    def recv_bottle_add(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        if ( 'bottle' in results.keys() ):
            bottleStr = results['bottle'][0]
        else:
            bottleStr = "#"

        content_type = 'text/html'

        data = bottleStr
        fp = StringIO(data)
        load_bulk_data.load_bottle_types(fp)
        #db.get_all_bottle_types()
        data = "Added Bottle Type: %s<p><a href='./'>Index</a>" % bottleStr

        start_response('200 OK', list(html_headers) )
        return [data]
Exemple #6
0
def start_load_bottle_types(path, print_output):
    db._reset_db()
    
    test_data_path = path
    fp = open(test_data_path, 'r')
    try:
        n = load_bulk_data.load_bottle_types(fp)
    except ValueError:
        print "\nIncorrect string format for \'load_bulk_data.load_bottle_types\' in \'%s\'." % test_data_path
        print "Correct usage: \'manufacturer name,liquor name,liquor type\'\n"
        pass
    
    if print_output:
        print "\n%s" % db._bottle_types_db
Exemple #7
0
 def load_bulk_data_types(self,file_name):
     return load_bulk_data.load_bottle_types(file_name)
Exemple #8
0
 def rpc_bottle_add( self, bottle ):
     data = bottle
     fp = StringIO(data)
     load_bulk_data.load_bottle_types(fp)