prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
<|fim_middle|>
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
<|fim_middle|>
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
<|fim_middle|>
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | result += int(form[index+1])
index += 1 |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
<|fim_middle|>
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | result -= int(form[index+1])
index += 1 |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
<|fim_middle|>
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | result *= int(form[index+1])
index += 1 |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
<|fim_middle|>
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | result //= int(form[index+1])
index += 1 |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
<|fim_middle|>
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | result += int(form[index]) |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
<|fim_middle|>
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | rightCombinations.append(formula) |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
<|fim_middle|>
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
<|fim_middle|>
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | listFinal.append("+") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
<|fim_middle|>
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | listFinal.append("-") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
<|fim_middle|>
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | listFinal.append("*") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
<|fim_middle|>
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | listFinal.append("/") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
<|fim_middle|>
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList) |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
<|fim_middle|>
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | newLine.append("+") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
<|fim_middle|>
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | newLine.append("-") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
<|fim_middle|>
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | newLine.append("*") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
<|fim_middle|>
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | newLine.append("/") |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def <|fim_middle|>(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | create_formula |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def <|fim_middle|>(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | evaluate |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def <|fim_middle|>(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def returnAllCombinations(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | countdown |
<|file_name|>src.py<|end_file_name|><|fim▁begin|>from itertools import permutations
import re
def create_formula(combination,numbers):
formula = ""
index = 0
for op in combination:
formula += str(numbers[index]) + op
index += 1
formula += numbers[index]
return formula
'''
Unnecessary Funtion
'''
def evaluate(form):
result = 0
for index in range(len(form)):
if form[index] == "+":
result += int(form[index+1])
index += 1
elif form[index] == "-":
result -= int(form[index+1])
index += 1
elif form[index] == "*":
result *= int(form[index+1])
index += 1
elif form[index] == "/":
result //= int(form[index+1])
index += 1
else:
result += int(form[index])
return result
def countdown(numbers):
rightCombinations = []
finalScore = numbers.pop()
combinations = returnAllCombinations(len(numbers) - 1)
perms = list(permutations(numbers))
for combination in combinations:
for permut in perms:
formula = create_formula(combination,permut)
#form = re.split("([*+-/])",formula)
#if int(evaluate(form)) == int(finalScore):
if int(eval(formula)) == int(finalScore):
rightCombinations.append(formula)
return rightCombinations
def <|fim_middle|>(size):
listFinal = []
for x in range(0,size):
if len(listFinal) == 0:
for y in range(0,4):
if y == 0:
listFinal.append("+")
elif y == 1:
listFinal.append("-")
elif y == 2:
listFinal.append("*")
else:
listFinal.append("/")
else:
newList = []
for l in listFinal:
for y in range(0,4):
newLine = list(l)
if y == 0:
newLine.append("+")
elif y == 1:
newLine.append("-")
elif y == 2:
newLine.append("*")
else:
newLine.append("/")
newList.append(newLine)
listFinal = list(newList)
return listFinal
out = open("output.txt",'w')
for line in open("input.txt",'r'):
for formula in countdown(line.split(" ")):
out.write(formula)
out.write("\n")
out.write("\n\n")
<|fim▁end|> | returnAllCombinations |
<|file_name|>pre_NAMD.py<|end_file_name|><|fim▁begin|># pre_NAMD.py
# Creates the files used for NAMD based on the .pdb file dowloaded from PDB bank
#
# Usage:
# python pre_NAMD.py $PDBID
#
# $PDBID=the 4 characters identification code of the .pdb file
#
# Input:
# $PDBID.pdb: .pdb file downloaded from PDB bank
#
# Output:
# $PDBID_p.pdb: .pdb file with water molecules removed
# $PDBID_p_h.pdb: .pdb file with water removed and hydrogen atoms added
# $PDBID_p_h.psf: .psf file of $PDBID_p_h.pdb
# $PDBID_p_h.log: Log file of adding hydrogen atoms
# $PDBID_wb.pdb: .pdb file of the water box model
# $PDBID_wb.psf: .psf file of $PDBID_wb.pdb
# $PDBID_wb.log: Log file of the water box model generation
# $PDBID_wb_i.pdb: .pdb file of the ionized water box model (For NAMD)
# $PDBID_wb_i.psf: .psf file of PDBID_wb_i.pdb (For NAMD)
# $PDBID.log: Log file of the whole process (output of VMD)
# $PDBID_center.txt: File contains the grid and center information of
# the ionized water box model<|fim▁hole|># Author: Xiaofei Zhang
# Date: June 20 2016
from __future__ import print_function
import sys, os
def print_error(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
# main
if len(sys.argv) != 2:
print_error("Usage: python pre_NAMD.py $PDBID")
sys.exit(-1)
mypath = os.path.realpath(__file__)
tclpath = os.path.split(mypath)[0] + os.path.sep + 'tcl' + os.path.sep
pdbid = sys.argv[1]
logfile = pdbid+'.log'
# Using the right path of VMD
vmd = "/Volumes/VMD-1.9.2/VMD 1.9.2.app/Contents/vmd/vmd_MACOSXX86"
print("Input: "+pdbid+".pdb")
# Remove water
print("Remove water..")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'remove_water.tcl' + ' ' + '-args' + ' '+ pdbid +'> '+ logfile
os.system(cmdline)
# Create .psf
print("Create PSF file...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'create_psf.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Build water box
print("Build water box...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'build_water_box.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Add ions
print("Add ions...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'add_ion.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Calculate grid and center
print("Calculate center coordinates...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'get_center.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
print("Finish!")
# end main<|fim▁end|> | # |
<|file_name|>pre_NAMD.py<|end_file_name|><|fim▁begin|># pre_NAMD.py
# Creates the files used for NAMD based on the .pdb file dowloaded from PDB bank
#
# Usage:
# python pre_NAMD.py $PDBID
#
# $PDBID=the 4 characters identification code of the .pdb file
#
# Input:
# $PDBID.pdb: .pdb file downloaded from PDB bank
#
# Output:
# $PDBID_p.pdb: .pdb file with water molecules removed
# $PDBID_p_h.pdb: .pdb file with water removed and hydrogen atoms added
# $PDBID_p_h.psf: .psf file of $PDBID_p_h.pdb
# $PDBID_p_h.log: Log file of adding hydrogen atoms
# $PDBID_wb.pdb: .pdb file of the water box model
# $PDBID_wb.psf: .psf file of $PDBID_wb.pdb
# $PDBID_wb.log: Log file of the water box model generation
# $PDBID_wb_i.pdb: .pdb file of the ionized water box model (For NAMD)
# $PDBID_wb_i.psf: .psf file of PDBID_wb_i.pdb (For NAMD)
# $PDBID.log: Log file of the whole process (output of VMD)
# $PDBID_center.txt: File contains the grid and center information of
# the ionized water box model
#
# Author: Xiaofei Zhang
# Date: June 20 2016
from __future__ import print_function
import sys, os
def print_error(*args, **kwargs):
<|fim_middle|>
# main
if len(sys.argv) != 2:
print_error("Usage: python pre_NAMD.py $PDBID")
sys.exit(-1)
mypath = os.path.realpath(__file__)
tclpath = os.path.split(mypath)[0] + os.path.sep + 'tcl' + os.path.sep
pdbid = sys.argv[1]
logfile = pdbid+'.log'
# Using the right path of VMD
vmd = "/Volumes/VMD-1.9.2/VMD 1.9.2.app/Contents/vmd/vmd_MACOSXX86"
print("Input: "+pdbid+".pdb")
# Remove water
print("Remove water..")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'remove_water.tcl' + ' ' + '-args' + ' '+ pdbid +'> '+ logfile
os.system(cmdline)
# Create .psf
print("Create PSF file...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'create_psf.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Build water box
print("Build water box...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'build_water_box.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Add ions
print("Add ions...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'add_ion.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Calculate grid and center
print("Calculate center coordinates...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'get_center.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
print("Finish!")
# end main
<|fim▁end|> | print(*args, file=sys.stderr, **kwargs) |
<|file_name|>pre_NAMD.py<|end_file_name|><|fim▁begin|># pre_NAMD.py
# Creates the files used for NAMD based on the .pdb file dowloaded from PDB bank
#
# Usage:
# python pre_NAMD.py $PDBID
#
# $PDBID=the 4 characters identification code of the .pdb file
#
# Input:
# $PDBID.pdb: .pdb file downloaded from PDB bank
#
# Output:
# $PDBID_p.pdb: .pdb file with water molecules removed
# $PDBID_p_h.pdb: .pdb file with water removed and hydrogen atoms added
# $PDBID_p_h.psf: .psf file of $PDBID_p_h.pdb
# $PDBID_p_h.log: Log file of adding hydrogen atoms
# $PDBID_wb.pdb: .pdb file of the water box model
# $PDBID_wb.psf: .psf file of $PDBID_wb.pdb
# $PDBID_wb.log: Log file of the water box model generation
# $PDBID_wb_i.pdb: .pdb file of the ionized water box model (For NAMD)
# $PDBID_wb_i.psf: .psf file of PDBID_wb_i.pdb (For NAMD)
# $PDBID.log: Log file of the whole process (output of VMD)
# $PDBID_center.txt: File contains the grid and center information of
# the ionized water box model
#
# Author: Xiaofei Zhang
# Date: June 20 2016
from __future__ import print_function
import sys, os
def print_error(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
# main
if len(sys.argv) != 2:
<|fim_middle|>
mypath = os.path.realpath(__file__)
tclpath = os.path.split(mypath)[0] + os.path.sep + 'tcl' + os.path.sep
pdbid = sys.argv[1]
logfile = pdbid+'.log'
# Using the right path of VMD
vmd = "/Volumes/VMD-1.9.2/VMD 1.9.2.app/Contents/vmd/vmd_MACOSXX86"
print("Input: "+pdbid+".pdb")
# Remove water
print("Remove water..")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'remove_water.tcl' + ' ' + '-args' + ' '+ pdbid +'> '+ logfile
os.system(cmdline)
# Create .psf
print("Create PSF file...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'create_psf.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Build water box
print("Build water box...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'build_water_box.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Add ions
print("Add ions...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'add_ion.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Calculate grid and center
print("Calculate center coordinates...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'get_center.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
print("Finish!")
# end main
<|fim▁end|> | print_error("Usage: python pre_NAMD.py $PDBID")
sys.exit(-1) |
<|file_name|>pre_NAMD.py<|end_file_name|><|fim▁begin|># pre_NAMD.py
# Creates the files used for NAMD based on the .pdb file dowloaded from PDB bank
#
# Usage:
# python pre_NAMD.py $PDBID
#
# $PDBID=the 4 characters identification code of the .pdb file
#
# Input:
# $PDBID.pdb: .pdb file downloaded from PDB bank
#
# Output:
# $PDBID_p.pdb: .pdb file with water molecules removed
# $PDBID_p_h.pdb: .pdb file with water removed and hydrogen atoms added
# $PDBID_p_h.psf: .psf file of $PDBID_p_h.pdb
# $PDBID_p_h.log: Log file of adding hydrogen atoms
# $PDBID_wb.pdb: .pdb file of the water box model
# $PDBID_wb.psf: .psf file of $PDBID_wb.pdb
# $PDBID_wb.log: Log file of the water box model generation
# $PDBID_wb_i.pdb: .pdb file of the ionized water box model (For NAMD)
# $PDBID_wb_i.psf: .psf file of PDBID_wb_i.pdb (For NAMD)
# $PDBID.log: Log file of the whole process (output of VMD)
# $PDBID_center.txt: File contains the grid and center information of
# the ionized water box model
#
# Author: Xiaofei Zhang
# Date: June 20 2016
from __future__ import print_function
import sys, os
def <|fim_middle|>(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
# main
if len(sys.argv) != 2:
print_error("Usage: python pre_NAMD.py $PDBID")
sys.exit(-1)
mypath = os.path.realpath(__file__)
tclpath = os.path.split(mypath)[0] + os.path.sep + 'tcl' + os.path.sep
pdbid = sys.argv[1]
logfile = pdbid+'.log'
# Using the right path of VMD
vmd = "/Volumes/VMD-1.9.2/VMD 1.9.2.app/Contents/vmd/vmd_MACOSXX86"
print("Input: "+pdbid+".pdb")
# Remove water
print("Remove water..")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'remove_water.tcl' + ' ' + '-args' + ' '+ pdbid +'> '+ logfile
os.system(cmdline)
# Create .psf
print("Create PSF file...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'create_psf.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Build water box
print("Build water box...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'build_water_box.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Add ions
print("Add ions...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'add_ion.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
# Calculate grid and center
print("Calculate center coordinates...")
cmdline = '\"'+ vmd + '\"' +' -dispdev text -eofexit < '+ tclpath + 'get_center.tcl' + ' ' + '-args' + ' '+ pdbid +'>> '+ logfile
os.system(cmdline)
print("Finish!")
# end main
<|fim▁end|> | print_error |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()<|fim▁hole|> exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()<|fim▁end|> | |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
<|fim_middle|>
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps") |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
<|fim_middle|>
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy) |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
<|fim_middle|>
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | return self.lobby.vbox.get_children()[-1].get_child() |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
<|fim_middle|>
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit) |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
<|fim_middle|>
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit) |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
<|fim_middle|>
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit) |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
<|fim_middle|>
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit) |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
<|fim_middle|>
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com") |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
<|fim_middle|>
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | """ regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps") |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
<|fim_middle|>
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')") |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
<|fim_middle|>
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')") |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
<|fim_middle|>
<|fim▁end|> | unittest.main() |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def <|fim_middle|>(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | setUp |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def <|fim_middle|>(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | _get_banner_from_lobby |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def <|fim_middle|>(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_featured_exhibit_by_default |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def <|fim_middle|>(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_no_exhibit_if_not_available |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def <|fim_middle|>(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_exhibit_if_available |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def <|fim_middle|>(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_exhibit_if_mixed_availability |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def <|fim_middle|>(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_exhibit_with_url |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def <|fim_middle|>(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def test_multiple_images(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_exhibit_with_featured_exhibit |
<|file_name|>test_exhibits.py<|end_file_name|><|fim▁begin|>import os
import unittest
from mock import patch, Mock
from tests.utils import (
FakedCache,
ObjectWithSignals,
setup_test_env,
)
setup_test_env()
from softwarecenter.db.database import StoreDatabase
from softwarecenter.ui.gtk3.views import lobbyview
from softwarecenter.ui.gtk3.widgets.exhibits import (
_HtmlRenderer,
)
class ExhibitsTestCase(unittest.TestCase):
"""The test suite for the exhibits carousel."""
def setUp(self):
self.cache = FakedCache()
self.db = StoreDatabase(cache=self.cache)
self.lobby = lobbyview.LobbyView(cache=self.cache, db=self.db,
icons=None, apps_filter=None)
self.addCleanup(self.lobby.destroy)
def _get_banner_from_lobby(self):
return self.lobby.vbox.get_children()[-1].get_child()
def test_featured_exhibit_by_default(self):
"""Show the featured exhibit before querying the remote service."""
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_no_exhibit_if_not_available(self):
"""The exhibit should not be shown if the package is not available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIsInstance(banner.exhibits[0], lobbyview.FeaturedExhibit)
def test_exhibit_if_available(self):
"""The exhibit should be shown if the package is available."""
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca, [exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_if_mixed_availability(self):
"""The exhibit should be shown even if some are not available."""
# available exhibit
exhibit = Mock()
exhibit.package_names = u'foobarbaz'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
self.cache[u'foobarbaz'] = Mock()
# not available exhibit
other = Mock()
other.package_names = u'not-there'
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit, other])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
self.lobby._append_banner_ads()
banner = self._get_banner_from_lobby()
self.assertEqual(1, len(banner.exhibits))
self.assertIs(banner.exhibits[0], exhibit)
def test_exhibit_with_url(self):
# available exhibit
exhibit = Mock()
exhibit.package_names = ''
exhibit.click_url = 'http://example.com'
exhibit.banner_urls = ['banner']
exhibit.title_translated = ''
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[exhibit])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby.exhibit_banner, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_exhibit = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "show-exhibits-clicked")
self.assertEqual(call_exhibit.click_url, "http://example.com")
def test_exhibit_with_featured_exhibit(self):
""" regression test for bug #1023777 """
sca = ObjectWithSignals()
sca.query_exhibits = lambda: sca.emit('exhibits', sca,
[lobbyview.FeaturedExhibit()])
with patch.object(lobbyview, 'SoftwareCenterAgent', lambda: sca):
# add the banners
self.lobby._append_banner_ads()
# fake click
alloc = self.lobby.exhibit_banner.get_allocation()
mock_event = Mock()
mock_event.x = alloc.x
mock_event.y = alloc.y
with patch.object(self.lobby, 'emit') as mock_emit:
self.lobby.exhibit_banner.on_button_press(None, mock_event)
self.lobby.exhibit_banner.on_button_release(None, mock_event)
mock_emit.assert_called()
signal_name = mock_emit.call_args[0][0]
call_category = mock_emit.call_args[0][1]
self.assertEqual(signal_name, "category-selected")
self.assertEqual(call_category.name, "Our star apps")
class HtmlRendererTestCase(unittest.TestCase):
def <|fim_middle|>(self):
downloader = ObjectWithSignals()
downloader.download_file = lambda *args, **kwargs: downloader.emit(
"file-download-complete", downloader, os.path.basename(args[0]))
with patch("softwarecenter.ui.gtk3.widgets.exhibits."
"SimpleFileDownloader", lambda: downloader):
renderer = _HtmlRenderer()
mock_exhibit = Mock()
mock_exhibit.banner_urls = [
"http://example.com/path1/banner1.png",
"http://example.com/path2/banner2.png",
]
mock_exhibit.html = "url('/path1/banner1.png')#"\
"url('/path2/banner2.png')"
renderer.set_exhibit(mock_exhibit)
# assert the stuff we expected to get downloaded got downloaded
self.assertEqual(
renderer._downloaded_banner_images,
["banner1.png", "banner2.png"])
# test that the path mangling worked
self.assertEqual(
mock_exhibit.html, "url('banner1.png')#url('banner2.png')")
if __name__ == "__main__":
unittest.main()
<|fim▁end|> | test_multiple_images |
<|file_name|>async_await.py<|end_file_name|><|fim▁begin|>import threading
import asyncio
async def hello():
print('Hello world! (%s)' % threading.currentThread())
await asyncio.sleep(1)
print('Hello again! (%s)' % threading.currentThread())
<|fim▁hole|>
loop = asyncio.get_event_loop()
tasks = [hello(), hello()]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()<|fim▁end|> | |
<|file_name|>async_await.py<|end_file_name|><|fim▁begin|>import threading
import asyncio
async def hello():
<|fim_middle|>
loop = asyncio.get_event_loop()
tasks = [hello(), hello()]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()<|fim▁end|> | print('Hello world! (%s)' % threading.currentThread())
await asyncio.sleep(1)
print('Hello again! (%s)' % threading.currentThread()) |
<|file_name|>async_await.py<|end_file_name|><|fim▁begin|>import threading
import asyncio
async def <|fim_middle|>():
print('Hello world! (%s)' % threading.currentThread())
await asyncio.sleep(1)
print('Hello again! (%s)' % threading.currentThread())
loop = asyncio.get_event_loop()
tasks = [hello(), hello()]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()<|fim▁end|> | hello |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",<|fim▁hole|> "binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}<|fim▁end|> | "browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: { |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
<|fim_middle|>
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port") |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
<|fim_middle|>
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
<|fim_middle|>
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
<|fim_middle|>
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
<|fim_middle|>
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return [] |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
<|fim_middle|>
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return {} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
<|fim_middle|>
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return {"webkit_port": kwargs["webkit_port"]} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
<|fim_middle|>
<|fim▁end|> | """Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
<|fim_middle|>
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args) |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
<|fim_middle|>
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | self.server.start(block=False) |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
<|fim_middle|>
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | self.server.stop(force=force) |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
<|fim_middle|>
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return self.server.pid |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
<|fim_middle|>
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | return self.server.is_alive |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
<|fim_middle|>
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | self.stop() |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
<|fim_middle|>
<|fim▁end|> | return ExecutorBrowser, {"webdriver_url": self.server.url} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
<|fim_middle|>
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}} |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def <|fim_middle|>(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | check_args |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def <|fim_middle|>(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | browser_kwargs |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def <|fim_middle|>(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | capabilities_for_port |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def <|fim_middle|>(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | executor_kwargs |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def <|fim_middle|>(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | env_extras |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def <|fim_middle|>():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | env_options |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def <|fim_middle|>(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | run_info_extras |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def <|fim_middle|>(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | __init__ |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def <|fim_middle|>(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | start |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def <|fim_middle|>(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | stop |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def <|fim_middle|>(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | pid |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def <|fim_middle|>(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | is_alive |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def <|fim_middle|>(self):
self.stop()
def executor_browser(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | cleanup |
<|file_name|>webkit.py<|end_file_name|><|fim▁begin|>from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
from ..executors.executorwebkit import WebKitDriverWdspecExecutor # noqa: F401
from ..webdriver_server import WebKitDriverServer
__wptrunner__ = {"product": "webkit",
"check_args": "check_args",
"browser": "WebKitBrowser",
"browser_kwargs": "browser_kwargs",
"executor": {"testharness": "WebDriverTestharnessExecutor",
"reftest": "WebDriverRefTestExecutor",
"wdspec": "WebKitDriverWdspecExecutor"},
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}
def check_args(**kwargs):
require_arg(kwargs, "binary")
require_arg(kwargs, "webdriver_binary")
require_arg(kwargs, "webkit_port")
def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"binary": kwargs["binary"],
"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args")}
def capabilities_for_port(server_config, **kwargs):
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port
return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}]}}
return {}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
cache_manager, run_info_data, **kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["capabilities"] = capabilities_for_port(server_config,
**kwargs)
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
return {}
def run_info_extras(**kwargs):
return {"webkit_port": kwargs["webkit_port"]}
class WebKitBrowser(Browser):
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
"""
def __init__(self, logger, binary, webdriver_binary=None,
webdriver_args=None):
Browser.__init__(self, logger)
self.binary = binary
self.server = WebKitDriverServer(self.logger, binary=webdriver_binary,
args=webdriver_args)
def start(self, **kwargs):
self.server.start(block=False)
def stop(self, force=False):
self.server.stop(force=force)
def pid(self):
return self.server.pid
def is_alive(self):
# TODO(ato): This only indicates the driver is alive,
# and doesn't say anything about whether a browser session
# is active.
return self.server.is_alive
def cleanup(self):
self.stop()
def <|fim_middle|>(self):
return ExecutorBrowser, {"webdriver_url": self.server.url}
<|fim▁end|> | executor_browser |
<|file_name|>destination.py<|end_file_name|><|fim▁begin|># coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Destination(Model):
"""Capture storage details for capture description.
:param name: Name for capture destination<|fim▁hole|> :param storage_account_resource_id: Resource id of the storage account to
be used to create the blobs
:type storage_account_resource_id: str
:param blob_container: Blob container Name
:type blob_container: str
:param archive_name_format: Blob naming convention for archive, e.g.
{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}.
Here all the parameters (Namespace,EventHub .. etc) are mandatory
irrespective of order
:type archive_name_format: str
"""
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'},
'blob_container': {'key': 'properties.blobContainer', 'type': 'str'},
'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'},
}
def __init__(self, name=None, storage_account_resource_id=None, blob_container=None, archive_name_format=None):
self.name = name
self.storage_account_resource_id = storage_account_resource_id
self.blob_container = blob_container
self.archive_name_format = archive_name_format<|fim▁end|> | :type name: str |
<|file_name|>destination.py<|end_file_name|><|fim▁begin|># coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Destination(Model):
<|fim_middle|>
<|fim▁end|> | """Capture storage details for capture description.
:param name: Name for capture destination
:type name: str
:param storage_account_resource_id: Resource id of the storage account to
be used to create the blobs
:type storage_account_resource_id: str
:param blob_container: Blob container Name
:type blob_container: str
:param archive_name_format: Blob naming convention for archive, e.g.
{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}.
Here all the parameters (Namespace,EventHub .. etc) are mandatory
irrespective of order
:type archive_name_format: str
"""
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'},
'blob_container': {'key': 'properties.blobContainer', 'type': 'str'},
'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'},
}
def __init__(self, name=None, storage_account_resource_id=None, blob_container=None, archive_name_format=None):
self.name = name
self.storage_account_resource_id = storage_account_resource_id
self.blob_container = blob_container
self.archive_name_format = archive_name_format |
<|file_name|>destination.py<|end_file_name|><|fim▁begin|># coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Destination(Model):
"""Capture storage details for capture description.
:param name: Name for capture destination
:type name: str
:param storage_account_resource_id: Resource id of the storage account to
be used to create the blobs
:type storage_account_resource_id: str
:param blob_container: Blob container Name
:type blob_container: str
:param archive_name_format: Blob naming convention for archive, e.g.
{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}.
Here all the parameters (Namespace,EventHub .. etc) are mandatory
irrespective of order
:type archive_name_format: str
"""
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'},
'blob_container': {'key': 'properties.blobContainer', 'type': 'str'},
'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'},
}
def __init__(self, name=None, storage_account_resource_id=None, blob_container=None, archive_name_format=None):
<|fim_middle|>
<|fim▁end|> | self.name = name
self.storage_account_resource_id = storage_account_resource_id
self.blob_container = blob_container
self.archive_name_format = archive_name_format |
<|file_name|>destination.py<|end_file_name|><|fim▁begin|># coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Destination(Model):
"""Capture storage details for capture description.
:param name: Name for capture destination
:type name: str
:param storage_account_resource_id: Resource id of the storage account to
be used to create the blobs
:type storage_account_resource_id: str
:param blob_container: Blob container Name
:type blob_container: str
:param archive_name_format: Blob naming convention for archive, e.g.
{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}.
Here all the parameters (Namespace,EventHub .. etc) are mandatory
irrespective of order
:type archive_name_format: str
"""
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'},
'blob_container': {'key': 'properties.blobContainer', 'type': 'str'},
'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'},
}
def <|fim_middle|>(self, name=None, storage_account_resource_id=None, blob_container=None, archive_name_format=None):
self.name = name
self.storage_account_resource_id = storage_account_resource_id
self.blob_container = blob_container
self.archive_name_format = archive_name_format
<|fim▁end|> | __init__ |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
<|fim▁hole|> raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
return {}<|fim▁end|> | if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)): |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
<|fim_middle|>
<|fim▁end|> | def get_vars(self, loader, path, entities, cache=True):
return {} |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
<|fim_middle|>
<|fim▁end|> | return {} |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
<|fim_middle|>
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
return {}
<|fim▁end|> | raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version)) |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
<|fim_middle|>
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
return {}
<|fim▁end|> | raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement)) |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
<|fim_middle|>
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
return {}
<|fim▁end|> | display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max)) |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
<|fim_middle|>
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
return {}
<|fim▁end|> | display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__)) |
<|file_name|>version.py<|end_file_name|><|fim▁begin|># Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
version_requirement = '2.5.0.0'
version_tested_max = '2.7.5'
python3_required_version = '2.5.3'
if version_info[0] == 3 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
raise AnsibleError(('Trellis no longer supports Ansible {}.\n'
'Please upgrade to Ansible {} or higher.').format(__version__, version_requirement))
elif gt(LooseVersion(__version__), LooseVersion(version_tested_max)):
display.warning(u'You Ansible version is {} but this version of Trellis has only been tested for '
u'compatability with Ansible {} -> {}. It is advisable to check for Trellis updates or '
u'downgrade your Ansible version.'.format(__version__, version_requirement, version_tested_max))
if eq(LooseVersion(__version__), LooseVersion('2.5.0')):
display.warning(u'You Ansible version is {}. Consider upgrading your Ansible version to avoid '
u'erroneous warnings such as `Removed restricted key from module data...`'.format(__version__))
# Import BaseVarsPlugin after Ansible version check.
# Otherwise import error for Ansible versions older than 2.4 would prevent display of version check message.
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def <|fim_middle|>(self, loader, path, entities, cache=True):
return {}
<|fim▁end|> | get_vars |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f<|fim▁hole|>
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))<|fim▁end|> | |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
<|fim_middle|>
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))
<|fim▁end|> | try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f
def get_name(f):
<|fim_middle|>
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))
<|fim▁end|> | from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f) |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
<|fim_middle|>
<|fim▁end|> | return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems()))) |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
<|fim_middle|>
if isinstance(f, Pipe):
return repr(f)
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))
<|fim▁end|> | return pipetools_name() if callable(pipetools_name) else pipetools_name |
<|file_name|>debug.py<|end_file_name|><|fim▁begin|>from itertools import imap, chain
def set_name(name, f):
try:
f.__pipetools__name__ = name
except (AttributeError, UnicodeEncodeError):
pass
return f
def get_name(f):
from pipetools.main import Pipe
pipetools_name = getattr(f, '__pipetools__name__', None)
if pipetools_name:
return pipetools_name() if callable(pipetools_name) else pipetools_name
if isinstance(f, Pipe):
<|fim_middle|>
return f.__name__ if hasattr(f, '__name__') else repr(f)
def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
imap('{0[0]}={0[1]!r}'.format, kwargs.iteritems())))
<|fim▁end|> | return repr(f) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.