Compare commits
15 Commits
revert-RJ4
...
remove-int
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114c6a5989 | ||
|
|
fe35b0aa91 | ||
|
|
b09f45f594 | ||
|
|
bc646b86c2 | ||
|
|
f4c19dec04 | ||
|
|
627e31ef37 | ||
|
|
b71eb244af | ||
|
|
85dc45a326 | ||
|
|
7e7b7f6467 | ||
|
|
ef186a3754 | ||
|
|
cc490fbc6a | ||
|
|
7daa9db4ed | ||
|
|
db7453f438 | ||
|
|
edcfcb4aac | ||
|
|
2ea9e2e702 |
@@ -1,4 +1,4 @@
|
||||
from python:3.5
|
||||
from python:3.6
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ AWS_S3_BUCKET="..."
|
||||
AWS_ACCESS_KEY_ID="..."
|
||||
AWS_SECRET_ACCESS_KEY="..."
|
||||
|
||||
SF_BASE_URL="https://test.salesforce.com"
|
||||
SFDC_BASE_URL="https://test.salesforce.com"
|
||||
SFDC_ACCESS_KEY_ID="..."
|
||||
SFDC_SECRET_ACCESS_KEY="..."
|
||||
SFDC_API_URL="https://sunpower--qa.cs8.my.salesforce.com"
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ def s3_upload(bytes_or_file_like, filename=None, file_extension=None):
|
||||
|
||||
# Assuming bucket already exists
|
||||
s3.Bucket(bucket_name).put_object(Key=filename, Body=bytes_or_file_like.read(), ACL='public-read')
|
||||
file_url = 'https://s3.amazonaws.com/{}/{}'.format(bucket_name, filename)
|
||||
# file_url = 'https://s3.amazonaws.com/{}/{}'.format(bucket_name, filename) # PermanentRedirect error
|
||||
file_url = 'https://{}.s3.amazonaws.com/{}'.format(bucket_name, filename)
|
||||
print('Uploaded filename {} to S3: {}'.format(filename, file_url))
|
||||
return file_url
|
||||
|
||||
@@ -4,9 +4,11 @@ from helix.calculators.subarray_helper import extract_subarray
|
||||
|
||||
from helix.constants.global_constants import minimum_racking_capacity
|
||||
from helix.constants.panel_type import PanelType
|
||||
from helix.constants.file_validation_error import FileValidationMessage,FileValidationException
|
||||
from helix.models.subarray import Subarray
|
||||
|
||||
|
||||
|
||||
class SeismicCalculator(object):
|
||||
def __init__(self, values, graph_repository):
|
||||
self.values = values
|
||||
@@ -37,13 +39,20 @@ class SeismicCalculator(object):
|
||||
more_anchors_needed = True
|
||||
perimeter_covered = sds < 1.0
|
||||
anchor_threshold = 0
|
||||
was_rung_empty = False
|
||||
while more_anchors_needed:
|
||||
rung = graph.pop_rung()
|
||||
interval = int(self.seismic_anchor_interval())
|
||||
nodes_since_last_anchor = interval
|
||||
if len(rung) == 0:
|
||||
if was_rung_empty:
|
||||
# detected an infinite loop
|
||||
# something is wrong with the input file
|
||||
# probably panels overlapping
|
||||
raise FileValidationException(FileValidationMessage.PanelsTooClose.value)
|
||||
graph.reset()
|
||||
anchor_threshold += 1
|
||||
was_rung_empty = True
|
||||
continue
|
||||
while more_anchors_needed and interval >= 0:
|
||||
for node in rung:
|
||||
|
||||
@@ -5,6 +5,7 @@ from helix.constants.global_constants import system_force_capacity
|
||||
|
||||
|
||||
class AnchorType(Enum):
|
||||
# These values are being used by Salesforce integration, do not change it
|
||||
OMG_PowerGrip = 'OMG PowerGrip'
|
||||
OMG_PowerGrip_Plus = 'OMG PowerGrip Plus'
|
||||
EcoFasten = 'EcoFasten Eco 65'
|
||||
|
||||
@@ -49,3 +49,7 @@ class FileValidationError(object):
|
||||
if self.__class__ != other.__class__:
|
||||
return False
|
||||
return self.row_number == other.row_number and self.validation_message == other.validation_message
|
||||
|
||||
class FileValidationException(Exception):
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
@@ -7,3 +7,5 @@ parapet_coefficients = 0.88, 1.2
|
||||
system_force_capacity = 418.
|
||||
|
||||
minimum_racking_capacity = 226
|
||||
|
||||
max_corner_angle = 135
|
||||
|
||||
@@ -2,6 +2,7 @@ from enum import Enum
|
||||
|
||||
|
||||
class ModuleType(Enum):
|
||||
# These values are being used by Salesforce integration, do not change it
|
||||
Cell96 = '96 Cell'
|
||||
Cell128 = '128 Cell'
|
||||
PSeries = 'P-Series'
|
||||
|
||||
@@ -5,12 +5,18 @@ except ImportError:
|
||||
|
||||
|
||||
class JsonBuilder:
|
||||
def build_bom_output(self, rows):
|
||||
def build_bom(self, rows):
|
||||
data = []
|
||||
headers = ['Part #', 'Description', 'Total']
|
||||
headers = ['itemId', 'description', 'quantity']
|
||||
for row in rows:
|
||||
d = {}
|
||||
for i, value in enumerate(row):
|
||||
d[headers[i]] = value
|
||||
data.append(d)
|
||||
return data
|
||||
|
||||
def bom_to_json(self, data):
|
||||
return json.dumps(data)
|
||||
|
||||
def build_bom_output(self, rows):
|
||||
return self.bom_to_json(self.build_bom(rows))
|
||||
|
||||
354
helix/main.py
354
helix/main.py
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
import requests
|
||||
from urllib.parse import urlparse
|
||||
import rollbar
|
||||
import rollbar.contrib.flask
|
||||
from flask import Flask, request, make_response, session, render_template, \
|
||||
redirect, url_for
|
||||
redirect, url_for, jsonify, flash
|
||||
from flask import got_request_exception
|
||||
from flask.ext import assets
|
||||
from flask_oauthlib.client import OAuth
|
||||
@@ -16,6 +17,7 @@ from helix.Services.dxf_service import DXFService
|
||||
from helix.api.api import api
|
||||
from helix.calculators.calculator import Calculator
|
||||
from helix.constants import redis_constant, sql_constant
|
||||
from helix.constants.file_validation_error import FileValidationError, FileValidationException
|
||||
from helix.constants.inverter_type import InverterType
|
||||
from helix.constants.system_type import SystemType
|
||||
from helix.csv_builder import CsvBuilder
|
||||
@@ -27,28 +29,48 @@ from helix.forms.input_form import InputForm, ArrayForm, TestDXFForm
|
||||
from helix.models.dxf.dxf_error import DXFError, OldDxfFormatException
|
||||
from helix.presenters.image_presenter import ImagePresenter
|
||||
from helix.presenters.panel_presenter import ProjectPresenter
|
||||
from helix.qa_helper import QAScenario
|
||||
from helix.session_manager import SessionManager
|
||||
from helix.validators.file_validator import FileValidator, FileType
|
||||
from helix.validators.subarray_validator import SubarrayValidator
|
||||
from flask_featureflags import FeatureFlag
|
||||
import flask_featureflags as feature
|
||||
import pprint
|
||||
|
||||
app = Flask(__name__)
|
||||
app.register_blueprint(api, url_prefix='/api')
|
||||
app.secret_key = os.getenv('SECRET_KEY', 'verysecretkey')
|
||||
app.config['PROFILE'] = True
|
||||
|
||||
app.config['FEATURE_FLAGS'] = {
|
||||
'ff_dummy_feature': True,
|
||||
'ff_cpp': True
|
||||
}
|
||||
|
||||
# Sales Force integrations
|
||||
FeatureFlag(app) # initializes feature flags
|
||||
|
||||
if feature.is_active('ff_dummy_feature'):
|
||||
app.logger.info('Feature flags working!')
|
||||
app.logger.info('Current state: ')
|
||||
app.logger.info(pprint.PrettyPrinter(width=41, compact=True).pformat(app.config['FEATURE_FLAGS']))
|
||||
|
||||
# Salesforce integrations
|
||||
oauth = OAuth()
|
||||
SF_BASE_URL = os.getenv('SFDC_BASE_URL', 'https://test.salesforce.com')
|
||||
sales_force = oauth.remote_app('sales_force',
|
||||
consumer_key=os.getenv('SFDC_ACCESS_KEY_ID'),
|
||||
consumer_secret=os.getenv('SFDC_SECRET_ACCESS_KEY'),
|
||||
base_url=SF_BASE_URL,
|
||||
request_token_url=None, # OAuth 2
|
||||
access_token_method='POST', # Sales Force requirement
|
||||
access_token_url=SF_BASE_URL + '/services/oauth2/token',
|
||||
authorize_url=SF_BASE_URL + '/services/oauth2/authorize',
|
||||
)
|
||||
SFDC_BASE_URL = os.getenv('SFDC_BASE_URL', 'https://test.salesforce.com')
|
||||
try:
|
||||
sales_force = oauth.remote_app('sales_force',
|
||||
consumer_key=os.getenv('SFDC_ACCESS_KEY_ID'),
|
||||
consumer_secret=os.getenv('SFDC_SECRET_ACCESS_KEY'),
|
||||
base_url=SFDC_BASE_URL,
|
||||
request_token_url=None, # OAuth 2
|
||||
access_token_method='POST', # Sales Force requirement
|
||||
access_token_url=SFDC_BASE_URL + '/services/oauth2/token',
|
||||
authorize_url=SFDC_BASE_URL + '/services/oauth2/authorize',
|
||||
)
|
||||
except TypeError:
|
||||
print('Salesforce integration disabled')
|
||||
sales_force = None
|
||||
|
||||
|
||||
assets_env = assets.Environment(app)
|
||||
assets_env.init_app(app)
|
||||
@@ -83,8 +105,8 @@ def init_rollbar():
|
||||
got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
|
||||
|
||||
|
||||
def is_sfdc_session():
|
||||
return 'SFID' in session
|
||||
def is_sales_force_session():
|
||||
return 'sf_session' in session
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@@ -129,7 +151,7 @@ def test_dxf():
|
||||
# wizard steps
|
||||
@app.route("/site_characterization/", methods=['GET', 'POST'])
|
||||
def site_characterization():
|
||||
if is_sfdc_session():
|
||||
if is_sales_force_session():
|
||||
return redirect('/summary/')
|
||||
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
@@ -177,13 +199,51 @@ def summary():
|
||||
else:
|
||||
context['no_proceed'] = True
|
||||
|
||||
if is_sfdc_session():
|
||||
if is_sales_force_session():
|
||||
context['hide_back'] = True
|
||||
|
||||
db_session.close()
|
||||
return render_template('site_summary.html.jinja', context=context)
|
||||
|
||||
|
||||
def handle_dxf_file(session_manager, file_contents, filename=None):
|
||||
errors = []
|
||||
user_values = session_manager.user_values()
|
||||
validator = FileValidator(user_values)
|
||||
calculator = Calculator(user_values, calculate_panel_data=False)
|
||||
|
||||
extension = os.path.splitext(filename)[1] or 'dxf'
|
||||
extension = extension.split('.')[-1]
|
||||
|
||||
validation_error = validator.validate(file_contents, FileType.AuroraDxf, extension=extension)
|
||||
if validation_error:
|
||||
error_msg = validation_error.format_error_message()
|
||||
errors.append(error_msg)
|
||||
else:
|
||||
try:
|
||||
module_constants = user_values.module_system_constants()
|
||||
# FIXME: parsing a file with many entities is very slow
|
||||
dxf_data = DXFService().parse(file_contents,
|
||||
module_constants,
|
||||
user_values.system_type(),
|
||||
calculator.L_B() * 12,
|
||||
DXFHelper(),
|
||||
SubarrayValidator())
|
||||
csv = CsvBuilder().build_cad_output(dxf_data['panels'])
|
||||
session_manager.save_uploaded_file(csv, dxf_file_name=filename)
|
||||
|
||||
buildings = dxf_data['buildings']
|
||||
session_manager.save_buildings_polygons(buildings)
|
||||
session_manager.save_is_drawing_inaccurate(dxf_data['is_panel_drawing_inaccurate'])
|
||||
|
||||
return True, errors
|
||||
except DXFError as error:
|
||||
errors.append(error.message)
|
||||
except OldDxfFormatException as error:
|
||||
errors.append(error.message)
|
||||
return False, errors
|
||||
|
||||
|
||||
@app.route("/array_summary/", methods=['GET', 'POST'])
|
||||
def array_summary():
|
||||
"""This endpoint allows you to upload a file.
|
||||
@@ -202,8 +262,7 @@ def array_summary():
|
||||
validator = FileValidator(session_manager.user_values())
|
||||
file = request.files['file_upload']
|
||||
file_contents = validator.obtain_stream(file)
|
||||
validation_error = validator.validate(file_contents, file,
|
||||
FileType.Csv)
|
||||
validation_error = validator.validate(file_contents, FileType.Csv, file)
|
||||
if not validation_error:
|
||||
session_manager.save_uploaded_file(file_contents,
|
||||
cad_file_name=file.filename)
|
||||
@@ -215,36 +274,15 @@ def array_summary():
|
||||
elif 'dxf_upload' in request.files and request.files['dxf_upload'].filename:
|
||||
file = request.files['dxf_upload']
|
||||
user_values = session_manager.user_values()
|
||||
calculator = Calculator(user_values, calculate_panel_data=False)
|
||||
validator = FileValidator(user_values)
|
||||
file_contents = validator.obtain_stream(file)
|
||||
validation_error = validator.validate(file_contents, file,
|
||||
FileType.AuroraDxf)
|
||||
if validation_error:
|
||||
error_msg = validation_error.format_error_message()
|
||||
array_form.dxf_upload.errors.append(error_msg)
|
||||
success, errors = handle_dxf_file(session_manager, file_contents, filename=file.filename)
|
||||
if success:
|
||||
if is_sales_force_session():
|
||||
session['sf_session']['new_dxf_file'] = True
|
||||
return redirect(url_for('array_summary'))
|
||||
else:
|
||||
try:
|
||||
module_constants = user_values.module_system_constants()
|
||||
# FIXME: parsing a file with many entities is very slow
|
||||
dxf_data = DXFService().parse(file_contents,
|
||||
module_constants,
|
||||
user_values.system_type(),
|
||||
calculator.L_B() * 12,
|
||||
DXFHelper(),
|
||||
SubarrayValidator())
|
||||
csv = CsvBuilder().build_cad_output(dxf_data['panels'])
|
||||
session_manager.save_uploaded_file(csv, dxf_file_name=file.filename)
|
||||
|
||||
buildings = dxf_data['buildings']
|
||||
session_manager.save_buildings_polygons(buildings)
|
||||
session_manager.save_is_drawing_inaccurate(dxf_data['is_panel_drawing_inaccurate'])
|
||||
|
||||
return redirect(url_for('array_summary'))
|
||||
except DXFError as error:
|
||||
array_form.dxf_upload.errors.append(error.message)
|
||||
except OldDxfFormatException as error:
|
||||
array_form.dxf_upload.errors.append(error.message)
|
||||
array_form.dxf_upload.errors.extend(errors)
|
||||
elif context['csv_available']:
|
||||
return redirect(url_for('power_station_configuration'))
|
||||
else:
|
||||
@@ -256,39 +294,91 @@ def array_summary():
|
||||
context['dxf_file_name'] = ''
|
||||
if context['site_data_available'] and context['csv_available']:
|
||||
user_values = session_manager.user_values()
|
||||
calculator = Calculator(user_values)
|
||||
system_type = user_values.system_type()
|
||||
module_type = user_values.module_type()
|
||||
project_presenter = ProjectPresenter(system_type, module_type)
|
||||
try:
|
||||
calculator = Calculator(user_values)
|
||||
system_type = user_values.system_type()
|
||||
module_type = user_values.module_type()
|
||||
project_presenter = ProjectPresenter(system_type, module_type)
|
||||
|
||||
context['wind_zones'] = system_type.system_constants().wind_zones
|
||||
context['summary_table'] = calculator.summary_table()
|
||||
context['minimum_array_sizes'] = calculator.minimum_array_sizes()
|
||||
context['seismic_anchors'] = calculator.subarray_summary()
|
||||
context['summary_values'] = calculator.summary_values()
|
||||
context['wind_zones'] = system_type.system_constants().wind_zones
|
||||
context['summary_table'] = calculator.summary_table()
|
||||
context['minimum_array_sizes'] = calculator.minimum_array_sizes()
|
||||
context['seismic_anchors'] = calculator.subarray_summary()
|
||||
context['summary_values'] = calculator.summary_values()
|
||||
|
||||
panels = calculator.get_computed_csv_columns()
|
||||
context['panel_array'] = project_presenter.get_panel_data(panels,
|
||||
calculator.subarrays,
|
||||
project_presenter.get_max_y(
|
||||
calculator.buildings_for_drawing,
|
||||
panels))
|
||||
context['buildings'] = project_presenter.get_buildings(calculator.buildings_for_drawing)
|
||||
context['override_form'] = True
|
||||
context['cad_file_name'] = session_manager.site.cad_file_name or 'Upload System Text Data'
|
||||
context['dxf_file_name'] = session_manager.site.dxf_file_name or 'Upload System DXF'
|
||||
context['is_drawing_inaccurate'] = session_manager.user_values().is_panel_drawing_inaccurate()
|
||||
context['inaccurate_drawing_warning'] = 'The subarrays in this design are not parallel to each other, \
|
||||
panels = calculator.get_computed_csv_columns()
|
||||
max_y = project_presenter.get_max_y(calculator.buildings_for_drawing,panels)
|
||||
context['panel_array'] = project_presenter.get_panel_data(panels,
|
||||
calculator.subarrays,
|
||||
max_y)
|
||||
context['buildings'] = project_presenter.get_buildings(calculator.buildings_for_drawing, max_y)
|
||||
context['corners'] = project_presenter.get_corners(calculator.buildings)
|
||||
context['override_form'] = True
|
||||
context['cad_file_name'] = session_manager.site.cad_file_name or 'Upload System Text Data'
|
||||
context['dxf_file_name'] = session_manager.site.dxf_file_name or 'Upload System DXF'
|
||||
context['is_drawing_inaccurate'] = session_manager.user_values().is_panel_drawing_inaccurate()
|
||||
context['inaccurate_drawing_warning'] = 'The subarrays in this design are not parallel to each other, \
|
||||
and the graphical representation on this page may not be accurate.'
|
||||
|
||||
except FileValidationException as error:
|
||||
# when calculator is about to enter infinte loop
|
||||
# it throws an exception - it is supplied wrong data
|
||||
context['site_data_available'] = False
|
||||
context['csv_available'] = False
|
||||
context['no_proceed'] = True
|
||||
context['cad_file_name'] = ''
|
||||
context['dxf_file_name'] = ''
|
||||
context['infinite_loop_detection_message'] = error.message
|
||||
|
||||
elif not context['site_data_available']:
|
||||
context['no_proceed'] = True
|
||||
|
||||
if is_sales_force_session() and \
|
||||
session['sf_session'].get('dxf_link', None) and \
|
||||
not session['sf_session'].get('dxf_link_loaded', None):
|
||||
|
||||
context['javascripts'].append('auto_dxf_load')
|
||||
|
||||
db_session.close()
|
||||
return render_template('array_summary.html.jinja', context=context, form=array_form)
|
||||
|
||||
|
||||
@app.route("/load_dxf/", methods=['GET', 'POST'])
|
||||
def load_dxf_file():
|
||||
if (not is_sales_force_session()) or session['sf_session'].get('dxf_link', None) is None:
|
||||
errors = ['DXF link not found']
|
||||
response = jsonify({'errors': errors})
|
||||
response.status_code = 404
|
||||
return response
|
||||
|
||||
dxf_link = session['sf_session'].get('dxf_link', None)
|
||||
if not dxf_link:
|
||||
session['sf_session']['dxf_link_loaded'] = True
|
||||
response = jsonify({'status': 'success', 'messages': ['No DXF file to load from Salesforce.']})
|
||||
response.status_code = 202
|
||||
return response
|
||||
|
||||
print('Loading DXF file from {}'.format(dxf_link))
|
||||
response = requests.get(dxf_link, timeout=30)
|
||||
if response.status_code == 200:
|
||||
file_contents = response.content.decode('utf-8')
|
||||
filename = urlparse(dxf_link).path.strip('/')
|
||||
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
session_manager = SessionManager(session, redis_constant.redis_store, db_session)
|
||||
|
||||
success, errors = handle_dxf_file(session_manager, file_contents, filename=filename)
|
||||
session['sf_session']['dxf_link_loaded'] = True
|
||||
if success:
|
||||
return jsonify({'status': 'success', 'messages': ['DXF from Salesforce loaded successfully.']})
|
||||
else:
|
||||
errors = ['Unable to download DXF file from Salesforce ({})'.format(response.status_code)]
|
||||
|
||||
response = jsonify({'errors': errors})
|
||||
response.status_code = 400
|
||||
return response
|
||||
|
||||
|
||||
@app.route("/power_station_configuration/", methods=['GET', 'POST'])
|
||||
def power_station_configuration():
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
@@ -367,6 +457,11 @@ def download():
|
||||
session_manager = SessionManager(session, redis_constant.redis_store, db_session)
|
||||
context = session_manager.context()
|
||||
context['current_step'] = 5
|
||||
if is_sales_force_session():
|
||||
error, data = session['sf_session'].pop('export_urls', (None, None))
|
||||
if data is not None:
|
||||
context['sfdc_export_error'] = error
|
||||
context['sfdc_export_urls'] = data
|
||||
db_session.close()
|
||||
return render_template('download.html.jinja', context=context)
|
||||
|
||||
@@ -456,68 +551,139 @@ def helix_documentation():
|
||||
return render_template('helix_documentation.jinja', context=context)
|
||||
|
||||
|
||||
# Sales Force Integration
|
||||
# Salesforce Integration
|
||||
@app.route('/sales_force_login')
|
||||
def sales_force_login():
|
||||
# To test it locally: https://localhost:8443/sales_force_login?SFID=a3cL00000004QsQIAU
|
||||
sfid = request.args.get('SFID')
|
||||
# To test it locally: https://localhost:8443/sales_force_login?sfid=a3cL00000004QsQIAU
|
||||
sfid = request.args.get('sfid')
|
||||
if sfid:
|
||||
session.clear()
|
||||
session['SFID'] = sfid
|
||||
return sales_force.authorize(callback=url_for('sales_force_authorized', _external=True, SFID=sfid), SFID=sfid)
|
||||
session['sf_session'] = {}
|
||||
session['sf_session']['sfid'] = sfid
|
||||
return sales_force.authorize(callback=url_for('sales_force_authorized', _external=True, sfid=sfid), sfid=sfid)
|
||||
else:
|
||||
flash('Missing sfid')
|
||||
return redirect('/')
|
||||
|
||||
|
||||
@app.route('/sales_force_authorized')
|
||||
def sales_force_authorized():
|
||||
if not is_sales_force_session():
|
||||
flash('This is not a Salesforce session')
|
||||
return redirect('/')
|
||||
|
||||
next_url = url_for('summary')
|
||||
|
||||
resp = sales_force.authorized_response()
|
||||
try:
|
||||
resp = sales_force.authorized_response()
|
||||
except Exception as e:
|
||||
flash('Error on authenticating to Salesforce.')
|
||||
print('Error on authenticating to Salesforce.')
|
||||
print(str(e))
|
||||
return sales_force_logout()
|
||||
|
||||
if resp is None:
|
||||
print('Unable to authenticate to SFDC.')
|
||||
flash('Unknown response from Salesforce.')
|
||||
print('Unknown response from Salesforce.')
|
||||
return redirect(next_url)
|
||||
|
||||
print('New Sales Force - OAuth2 login')
|
||||
print('New Salesforce - OAuth2 login')
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
session_manager = SessionManager(session, redis_constant.redis_store, db_session)
|
||||
session['sales_force_token'] = resp['access_token']
|
||||
session['sf_session']['access_token'] = resp['access_token']
|
||||
|
||||
data = sf_tasks.get_site_characterization_from_sales_force(session, resp['instance_url'])
|
||||
if data:
|
||||
session_manager.save_form_submission(data)
|
||||
return redirect(next_url)
|
||||
else:
|
||||
helix_session_id = session['id']
|
||||
access_token = session['sf_session']['access_token']
|
||||
sfid = session['sf_session']['sfid']
|
||||
try:
|
||||
data, status_code = sf_tasks.get_site_characterization_from_sales_force(helix_session_id, access_token, sfid)
|
||||
if data and status_code == 200:
|
||||
session['sf_session']['dxf_link'] = data['dxf_link']
|
||||
session_manager.save_form_submission(data)
|
||||
flash('Connected to Salesforce.')
|
||||
return redirect(next_url)
|
||||
else:
|
||||
flash('Unable to get site characterization from Salesforce. ({})'.format(status_code))
|
||||
return sales_force_logout()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
flash('Unable to get site characterization from Salesforce.')
|
||||
return sales_force_logout()
|
||||
|
||||
|
||||
# FIXME
|
||||
from flask import jsonify
|
||||
@app.route("/export-sfdc")
|
||||
def export_sfdc():
|
||||
if not is_sfdc_session():
|
||||
if not is_sales_force_session():
|
||||
flash('This is not a Salesforce session')
|
||||
return redirect('/')
|
||||
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
session_manager = SessionManager(session, redis_constant.redis_store, db_session)
|
||||
session_id = session_manager.session['id']
|
||||
data = sf_tasks.export_to_sfdc(session_id)
|
||||
helix_session_id = session_manager.session['id']
|
||||
sf_session = session['sf_session']
|
||||
access_token = sf_session['access_token']
|
||||
sfid = sf_session['sfid']
|
||||
new_dxf_file = sf_session.get('new_dxf_file', False)
|
||||
error, data = sf_tasks.export_to_sfdc(helix_session_id, access_token, sfid, new_dxf_file=new_dxf_file, qa_test=session.get('qa_test', None))
|
||||
data.pop('bom', None)
|
||||
data['dxfUrlFromSF'] = sf_session['dxf_link']
|
||||
sf_session['export_urls'] = (error, data)
|
||||
db_session.close()
|
||||
return jsonify(data)
|
||||
# return redirect('/download')
|
||||
return redirect('/download')
|
||||
|
||||
|
||||
@sales_force.tokengetter
|
||||
def get_sales_force_token(token=None):
|
||||
return session.get('sales_force_token')
|
||||
if sales_force:
|
||||
@sales_force.tokengetter
|
||||
def get_sales_force_token(token=None):
|
||||
return session.get('sf_session', {}).get('access_token', None)
|
||||
|
||||
|
||||
@app.route('/sales_force_logout')
|
||||
def sales_force_logout():
|
||||
session.pop('SFID', None)
|
||||
session.pop('sales_force_token', None)
|
||||
session.clear()
|
||||
session.pop('sf_session', None)
|
||||
return redirect('/')
|
||||
# End of Sales Force Integration
|
||||
# End of Salesforce Integration
|
||||
|
||||
|
||||
# QA scenario simulations
|
||||
|
||||
@app.route('/qa')
|
||||
def qa_simulations():
|
||||
test = request.args.get('test', None)
|
||||
bad_request = None
|
||||
if not test:
|
||||
bad_request = 'Missing `test` parameter.'
|
||||
elif test not in QAScenario.all():
|
||||
bad_request = 'Unknown test scenario: <b>' + test + '</b>.'
|
||||
if bad_request:
|
||||
tests = ''.join(['<li><a href="/qa?test=' + s + '">' + s + '</a></li>' for s in QAScenario.all()])
|
||||
tests = '<ul>' + tests + '</ul>'
|
||||
return bad_request + tests, 400
|
||||
|
||||
if test.startswith('sf_') and 'sf_session' not in session:
|
||||
return 'Please, connect to Salesforce first.', 400
|
||||
|
||||
url = None
|
||||
if test == QAScenario.SF_RESET_ALL.value:
|
||||
session['sf_session']['dxf_link_loaded'] = False
|
||||
session['qa_test'] = None
|
||||
url = request.url_root
|
||||
elif test == QAScenario.SF_NO_DXF.value:
|
||||
session['sf_session']['dxf_link'] = None
|
||||
session['sf_session']['dxf_link_loaded'] = False
|
||||
url = request.url_root + 'array_summary/'
|
||||
elif test == QAScenario.SF_VALID_DXF.value:
|
||||
session['sf_session']['dxf_link'] = 'https://sunpower-test-dgplatform-spectrum.s3.amazonaws.com/a5FL00000008gKcMAI-DXF.dxf'
|
||||
session['sf_session']['dxf_link_loaded'] = False
|
||||
url = request.url_root + 'array_summary/'
|
||||
elif test in (QAScenario.SF_ERROR_UPLOAD_S3.value, QAScenario.SF_ERROR_NOTIFY_SF.value):
|
||||
session['qa_test'] = test
|
||||
url = request.url_root + 'export-sfdc'
|
||||
|
||||
msg = '<b>' + test + '</b> test enabled.'
|
||||
if url:
|
||||
msg += ' Access: <a href="' + url + '">' + url + '</a> to check.'
|
||||
return msg, 200
|
||||
|
||||
|
||||
@app.template_filter('format_number')
|
||||
|
||||
13
helix/models/corner.py
Normal file
13
helix/models/corner.py
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
class Corner(object):
|
||||
def __init__(self, x, y, length_ccw, length_cw, angle):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.length_ccw = length_ccw
|
||||
self.length_cw = length_cw
|
||||
self.angle = angle
|
||||
|
||||
@property
|
||||
def dictionary(self):
|
||||
return {"x": self.x, "y": self.y, "length_ccw": self.length_ccw, "length_cw": self.length_cw, "angle": self.angle}
|
||||
@@ -1,4 +1,8 @@
|
||||
import sys
|
||||
from math import sqrt, degrees, acos
|
||||
from helix.models.corner import Corner
|
||||
from helix.constants.global_constants import max_corner_angle
|
||||
import flask_featureflags as feature
|
||||
|
||||
class ProjectPresenter(object):
|
||||
def __init__(self, system_type, module_type):
|
||||
@@ -18,8 +22,6 @@ class ProjectPresenter(object):
|
||||
spacing_x, spacing_y = module_constants.presenter_spacing
|
||||
wind_zones = system_constants.wind_zones
|
||||
|
||||
|
||||
|
||||
for panel in panels:
|
||||
subarray = [x for x in subarrays if x.subarray_number == panel.subarray][0]
|
||||
origin = subarray.origin
|
||||
@@ -50,9 +52,10 @@ class ProjectPresenter(object):
|
||||
self.offset = height
|
||||
for panel in table_data:
|
||||
panel['y'] = height - panel['y'] + first_cell
|
||||
|
||||
return table_data
|
||||
|
||||
def get_buildings(self, buildings):
|
||||
def get_buildings(self, buildings, max_y):
|
||||
if self.offset is None:
|
||||
self.offset = 0
|
||||
|
||||
@@ -67,11 +70,50 @@ class ProjectPresenter(object):
|
||||
# origin = self.find_origin(building)
|
||||
for point in building:
|
||||
point.x = point.x * spacing_x
|
||||
point.y = point.y * spacing_y
|
||||
point.y = abs((point.y * spacing_y) - max_y)
|
||||
presentable_building.append(point.__dict__)
|
||||
|
||||
return result
|
||||
|
||||
def get_corners(self, buildings):
|
||||
|
||||
def angle(x1, y1, x2, y2):
|
||||
# Use dotproduct to find angle between vectors
|
||||
# This always returns an angle between 0, pi
|
||||
numer = (x1 * x2 + y1 * y2)
|
||||
denom = sqrt((x1 ** 2 + y1 ** 2) * (x2 ** 2 + y2 ** 2))
|
||||
return acos(numer / denom)
|
||||
|
||||
|
||||
def cross_sign(x1, y1, x2, y2):
|
||||
# True if cross is positive
|
||||
# False if negative or zero
|
||||
return x1 * y2 > x2 * y1
|
||||
|
||||
result = []
|
||||
if feature.is_active('ff_cpp'):
|
||||
for building in buildings:
|
||||
presentable_building = []
|
||||
result.append(presentable_building)
|
||||
|
||||
for i in range(len(building)):
|
||||
p1 = building[i]
|
||||
ref = building[i - 1]
|
||||
p2 = building[i - 2]
|
||||
x1, y1 = p1[0] - ref[0], p1[1] - ref[1]
|
||||
x2, y2 = p2[0] - ref[0], p2[1] - ref[1]
|
||||
|
||||
corner_length_cw = sqrt(x2**2 + y2**2)
|
||||
corner_length_ccw = sqrt(x1**2 + y1**2)
|
||||
theta = degrees(angle(x1, y1, x2, y2))
|
||||
|
||||
#print('Points', p1, ref, p2)
|
||||
#print('Angle', theta)
|
||||
if (cross_sign(x1, y1, x2, y2)) and (theta < max_corner_angle) :
|
||||
#print('Inner Angle')
|
||||
presentable_building.append(Corner(ref[0], ref[1], corner_length_ccw,corner_length_cw, theta).__dict__)
|
||||
return result
|
||||
|
||||
def get_max_y(self,buildings, panels):
|
||||
|
||||
module_constants = self.system_type.module_constants(self.module_type)
|
||||
|
||||
20
helix/qa_helper.py
Normal file
20
helix/qa_helper.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class QAException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class QAScenario(Enum):
|
||||
SF_NO_DXF = 'sf_no_dxf'
|
||||
SF_ERROR_UPLOAD_S3 = 'sf_error_upload_s3'
|
||||
SF_ERROR_NOTIFY_SF = 'sf_error_notify_sf'
|
||||
SF_VALID_DXF = 'sf_valid_dxf'
|
||||
SF_RESET_ALL = 'sf_reset_all'
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s.%s>' % (self.__class__.__name__, self.name)
|
||||
|
||||
@classmethod
|
||||
def all(cls):
|
||||
return [s.value for s in list(cls)]
|
||||
@@ -1,5 +1,5 @@
|
||||
import io
|
||||
import uuid
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
@@ -11,51 +11,54 @@ from helix.doc_gen_params_builder import DocGenParamsBuilder
|
||||
from helix.helpers.camel_case import convert_dict_keys_to_snake_case
|
||||
from helix.json_builder import JsonBuilder
|
||||
from helix.presenters.image_presenter import ImagePresenter
|
||||
from helix.qa_helper import QAScenario, QAException
|
||||
from helix.Services.doc_gen_service import DocGenService
|
||||
from helix.Services.s3_helper import s3_upload
|
||||
from helix.session_manager import SessionManager
|
||||
|
||||
|
||||
def get_site_characterization_from_sales_force(session, base_url):
|
||||
'''
|
||||
@base_url: Avoid URL_NOT_RESET errors
|
||||
'''
|
||||
access_token = session['sales_force_token']
|
||||
sfid = session['SFID']
|
||||
helix_id = session['id']
|
||||
url = base_url + '/services/apexrest/v1/HelixRoofDetails'
|
||||
def get_site_characterization_from_sales_force(helix_session_id, access_token, sfid):
|
||||
SFDC_API_URL = os.getenv('SFDC_API_URL', 'https://sunpower--qa.cs8.my.salesforce.com')
|
||||
url = SFDC_API_URL + '/services/apexrest/v1/HelixRoofDetails'
|
||||
headers = {'Authorization': 'Bearer {}'.format(access_token)}
|
||||
result = requests.get(url, headers=headers, params={'SFID': sfid, 'helix_session_id': helix_id})
|
||||
params = {'sfid': sfid, 'helix_session_id': helix_session_id}
|
||||
result = requests.get(url, headers=headers, params=params, timeout=30)
|
||||
if result.status_code == 200:
|
||||
data = result.json()
|
||||
if data:
|
||||
data = convert_sales_force_data_format_to_helix(data)
|
||||
return data
|
||||
return data, 200
|
||||
else:
|
||||
print('Error while getting data from Sales Force: {}'.format(result.status_code))
|
||||
print('Error while getting data from Salesforce ({})'.format(result.status_code))
|
||||
print(url, params)
|
||||
print(result.content)
|
||||
# print(result.request.headers)
|
||||
return None, result.status_code
|
||||
|
||||
|
||||
def convert_sales_force_data_format_to_helix(data):
|
||||
data = convert_dict_keys_to_snake_case(data)
|
||||
|
||||
if data['system_type'] == 'Single-Tilt':
|
||||
if data['system_type'] in ('Single-Tilt', 'Single Tilt'):
|
||||
data['system_type'] = SystemType.singleTilt.value
|
||||
elif data['system_type'] == 'Dual-Tilt':
|
||||
elif data['system_type'] == ('Dual-Tilt', 'Dual Tilt'):
|
||||
data['system_type'] = SystemType.dualTilt.value
|
||||
|
||||
if data['anchor_type'] == 'OMG Power Grip Plus':
|
||||
data['anchor_type'] = 'OMG PowerGrip Plus'
|
||||
|
||||
data['ballast_block_weight'] = data['ballast_weight']
|
||||
data['max_system_pressure'] = data['max_psf'] = data['system_pressure']
|
||||
return data
|
||||
# data['spectral_response_acceleration']
|
||||
|
||||
|
||||
def export_to_sfdc(session_id):
|
||||
step = 'Exporting to SFDC'
|
||||
def export_to_sfdc(helix_session_id, access_token, sfid, new_dxf_file=False, qa_test=None):
|
||||
step = 'Exporting to Salesforce'
|
||||
try:
|
||||
# 1. Load User Values
|
||||
step = 'Loading User Values'
|
||||
session = {'id': session_id}
|
||||
session = {'id': helix_session_id}
|
||||
db_session = sql_constant.sql_session_maker()
|
||||
session_manager = SessionManager(session, redis_constant.redis_store, db_session)
|
||||
user_values = session_manager.user_values()
|
||||
@@ -67,7 +70,9 @@ def export_to_sfdc(session_id):
|
||||
csv_file = CsvBuilder().build_bom_output(bom)
|
||||
# 2.1 Generate BOM CSV file
|
||||
step = 'Generating BOM as JSON'
|
||||
json_str = JsonBuilder().build_bom_output(bom)
|
||||
json_builder = JsonBuilder()
|
||||
bom_list = json_builder.build_bom(bom)
|
||||
bom_list_json = json_builder.bom_to_json(bom_list)
|
||||
|
||||
# 3. Generate DOCUMENTATION PDF file
|
||||
step = 'Generating Documentation'
|
||||
@@ -82,37 +87,52 @@ def export_to_sfdc(session_id):
|
||||
|
||||
# 5. Save CSV/PDF/DXF files into AWS-S3
|
||||
step = 'Uploading to S3'
|
||||
filename = uuid.uuid4().hex
|
||||
bom_csv_url = s3_upload(io.StringIO(csv_file), filename=filename + '.csv')
|
||||
bom_json_url = s3_upload(io.StringIO(json_str), filename=filename + '.json')
|
||||
doc_url = s3_upload(io.BytesIO(document), filename=filename + '.pdf')
|
||||
if dxf_contents: # Optional
|
||||
dxf_url = s3_upload(io.StringIO(dxf_contents), filename=filename + '.dxf')
|
||||
if qa_test == QAScenario.SF_ERROR_UPLOAD_S3.value:
|
||||
raise QAException(qa_test)
|
||||
|
||||
bom_csv_url = s3_upload(io.StringIO(csv_file), filename=sfid + '-csv.csv')
|
||||
doc_url = s3_upload(io.BytesIO(document), filename=sfid + '-pdf.pdf')
|
||||
bom_json_url = s3_upload(io.StringIO(bom_list_json), filename=sfid + '-json.json')
|
||||
# Send only if the file DXF file was uploaded in Helix
|
||||
if new_dxf_file and dxf_contents: # Optional
|
||||
dxf_url = s3_upload(io.StringIO(dxf_contents), filename=sfid + '-dxf.dxf')
|
||||
else:
|
||||
dxf_url = None
|
||||
|
||||
# 6. Notify SFDC system with an API request
|
||||
step = 'Notifying SFDC'
|
||||
SFDC_API_URL = 'https://localhost:8443/' # FIXME
|
||||
data = {
|
||||
'dxf_url': dxf_url,
|
||||
'bom_csv_url': bom_csv_url,
|
||||
'bom_json_url': bom_json_url,
|
||||
'documentation_url': doc_url,
|
||||
}
|
||||
print(data)
|
||||
# result = requests.post(SFDC_API_URL, data=data, timeout=30)
|
||||
step = 'Notifying Salesforce'
|
||||
if qa_test == QAScenario.SF_ERROR_NOTIFY_SF.value:
|
||||
raise QAException(qa_test)
|
||||
|
||||
data = {
|
||||
'dxfUrl': dxf_url,
|
||||
'bomCsvUrl': bom_csv_url,
|
||||
'documentationUrl': doc_url,
|
||||
'bom': bom_list,
|
||||
'helixSessionId': helix_session_id,
|
||||
'sfid': sfid,
|
||||
}
|
||||
headers = {'Authorization': 'Bearer {}'.format(access_token)}
|
||||
SFDC_API_URL = os.getenv('SFDC_API_URL', 'https://sunpower--qa.cs8.my.salesforce.com')
|
||||
url = SFDC_API_URL + '/services/apexrest/v1/HelixRoofDetails'
|
||||
result = requests.post(url, headers=headers, json=data, timeout=30)
|
||||
# 7. Internal logs
|
||||
# if result.status_code != 200: # FIXME
|
||||
# print('')
|
||||
# else:
|
||||
# print('')
|
||||
if result.status_code <= 299:
|
||||
print('Salesforce notified successfully for session {}.'.format(helix_session_id))
|
||||
# print(result.content)
|
||||
error = None
|
||||
else:
|
||||
error = 'Helix Calculator was not able to notify Salesforce ({})'.format(result.status_code)
|
||||
|
||||
print(error)
|
||||
print(result.content)
|
||||
|
||||
# Only Helix need this information for audit
|
||||
data['bomJsonUrl'] = bom_json_url
|
||||
|
||||
db_session.close()
|
||||
return data
|
||||
# return result.status_code
|
||||
return error, data
|
||||
except Exception as e:
|
||||
msg = 'Error while {} for session {}'.format(step, session_id)
|
||||
print(msg)
|
||||
raise e
|
||||
print('Error while {} for session {}'.format(step, helix_session_id))
|
||||
error = 'Error while {}'.format(step)
|
||||
return error, {}
|
||||
|
||||
@@ -72,6 +72,12 @@ i.icon-info-circled {
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.info_message {
|
||||
color: black;
|
||||
padding-left: 5px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.error_message {
|
||||
color: red;
|
||||
padding-left: 5px;
|
||||
@@ -151,7 +157,7 @@ a.back {
|
||||
a {
|
||||
text-decoration: none;
|
||||
width: auto;
|
||||
margin: 0 5px;
|
||||
margin: 2px 5px;
|
||||
}
|
||||
|
||||
.button {
|
||||
|
||||
@@ -59,3 +59,35 @@ h1 {
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.spinner-panel {
|
||||
position: fixed;
|
||||
margin: 0 auto;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0; /* It will be updated to 100% in JS. Workaround for Safari issue with display:none; */
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
z-index: 1;
|
||||
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
.msg-container {
|
||||
background-color: $off-white;
|
||||
border: 1px solid $medium-border-color;
|
||||
margin: 20px;
|
||||
padding: 10px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
.msg-container li {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
@@ -81,17 +81,17 @@ class SessionManager(object):
|
||||
building_height=form_data.get('building_height', 0),
|
||||
building_width=form_data.get('building_width', 0),
|
||||
building_length=form_data.get('building_length', 0),
|
||||
parapet_height=form_data.get('building_parapet_height', 0),
|
||||
parapet_height=form_data.get('parapet_height', form_data.get('building_parapet_height', 0)),
|
||||
wind_speed=form_data.get('wind_speed', 0),
|
||||
exposure_category=form_data.get('exposure_category', 'C'),
|
||||
exposure_transition_distance=form_data.get('exposure_category_transition_distance', 0),
|
||||
ballast_block_weight=form_data.get('ballast_block_weight', 0),
|
||||
max_psf=form_data.get('max_system_pressure', 0),
|
||||
ballast_block_weight=form_data.get('ballast_block_weight', form_data.get('ballast_weight', 0)),
|
||||
max_psf=form_data.get('system_pressure', form_data.get('max_system_pressure', form_data.get('max_psf', 0))),
|
||||
system_type=form_data.get('system_type', SystemType.dualTilt.value),
|
||||
module_type=form_data.get('module_type', ModuleType.Cell96.value),
|
||||
anchor_type=form_data.get('anchor_type', AnchorType.OMG_PowerGrip_Plus.value),
|
||||
spectral_response=form_data.get('design_spectral_response', 1),
|
||||
seismic_importance_factor=form_data.get('importance_factor', 1)
|
||||
spectral_response=form_data.get('design_spectral_response', form_data.get('spectral_response_acceleration', form_data.get('spectral_response', 1))),
|
||||
seismic_importance_factor=form_data.get('seismic_importance_factor', form_data.get('importance_factor', 1))
|
||||
)
|
||||
self.db_session.add(self.site)
|
||||
self.db_session.commit()
|
||||
|
||||
@@ -616,13 +616,20 @@ i.icon-info-circled {
|
||||
}
|
||||
|
||||
/* line 75 */
|
||||
.info_message {
|
||||
color: black;
|
||||
padding-left: 5px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* line 81 */
|
||||
.error_message {
|
||||
color: red;
|
||||
padding-left: 5px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* line 81 */
|
||||
/* line 87 */
|
||||
input, select {
|
||||
width: calc(100% - 20px);
|
||||
padding: 10px;
|
||||
@@ -633,7 +640,7 @@ input, select {
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
/* line 91 */
|
||||
/* line 97 */
|
||||
select {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
@@ -641,14 +648,14 @@ select {
|
||||
background: #F4F4F4 url("https://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat calc(100% - 15px);
|
||||
}
|
||||
|
||||
/* line 98 */
|
||||
/* line 104 */
|
||||
.submit, .download {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-top: 1px solid #EAEAEA;
|
||||
}
|
||||
|
||||
/* line 104 */
|
||||
/* line 110 */
|
||||
.button, button {
|
||||
background: #5199F5;
|
||||
color: white;
|
||||
@@ -660,7 +667,7 @@ select {
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
/* line 115 */
|
||||
/* line 121 */
|
||||
.navigation_buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
@@ -668,18 +675,18 @@ select {
|
||||
border-bottom: 1px solid #EAEAEA;
|
||||
padding: 20px;
|
||||
}
|
||||
/* line 122 */
|
||||
/* line 128 */
|
||||
.navigation_buttons a {
|
||||
text-decoration: none;
|
||||
width: auto;
|
||||
margin: 0 20px;
|
||||
}
|
||||
/* line 128 */
|
||||
/* line 134 */
|
||||
.navigation_buttons .button {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* line 133 */
|
||||
/* line 139 */
|
||||
.back {
|
||||
border: 2px solid #5199F5;
|
||||
color: #5199F5;
|
||||
@@ -687,12 +694,12 @@ select {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
/* line 140 */
|
||||
/* line 146 */
|
||||
a.back {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* line 144 */
|
||||
/* line 150 */
|
||||
.sample_images {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
@@ -700,18 +707,18 @@ a.back {
|
||||
border-bottom: 1px solid #EAEAEA;
|
||||
padding: 15px;
|
||||
}
|
||||
/* line 151 */
|
||||
/* line 157 */
|
||||
.sample_images a {
|
||||
text-decoration: none;
|
||||
width: auto;
|
||||
margin: 2px 5px;
|
||||
}
|
||||
/* line 157 */
|
||||
/* line 163 */
|
||||
.sample_images .button {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* line 162 */
|
||||
/* line 168 */
|
||||
.image_button, button {
|
||||
background: #5199F5;
|
||||
color: white;
|
||||
@@ -832,6 +839,41 @@ h1 {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
/* line 63 */
|
||||
.spinner-panel {
|
||||
position: fixed;
|
||||
margin: 0 auto;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0;
|
||||
/* It will be updated to 100% in JS. Workaround for Safari issue with display:none; */
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* line 84 */
|
||||
.msg-container {
|
||||
background-color: #FDFDFD;
|
||||
border: 1px solid #D8D8D8;
|
||||
margin: 20px;
|
||||
padding: 10px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
/* line 91 */
|
||||
.msg-container li {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
/* line 3 */
|
||||
.navigation_header {
|
||||
display: flex;
|
||||
@@ -1023,21 +1065,3 @@ table .right_border_cell {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.spinner-panel {
|
||||
position: fixed;
|
||||
margin: 0 auto;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0; /* It will be updated to 100% in JS. Workaround for Safari issue with display:none; */
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
z-index: 1;
|
||||
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
30
helix/static/javascripts/auto_dxf_load.js
Normal file
30
helix/static/javascripts/auto_dxf_load.js
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#sf_msg_container").empty();
|
||||
$('#sf-spinner-panel').css('width', '100%'); // Workaround for Safari issue
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/load_dxf/'
|
||||
}).done(function(data, textStatus, jqXHR) { // 200 or 202
|
||||
if (data && data.messages) {
|
||||
data.messages.forEach((msg) => {
|
||||
$("#sf_msg_container").append('<li class="info_message">' + msg + '</li>');
|
||||
})
|
||||
$("#sf_msg_container").show();
|
||||
}
|
||||
if (jqXHR.status == 200) {
|
||||
setTimeout(function() { window.location.reload() }, 1000);
|
||||
}
|
||||
}).fail(function(jqXHR, textStatus, errorThrown) { // 400, 404, 5xx
|
||||
// console.log(jqXHR, textStatus, errorThrown)
|
||||
if (jqXHR.responseJSON && jqXHR.responseJSON.errors) {
|
||||
jqXHR.responseJSON.errors.forEach((msg) => {
|
||||
$("#sf_msg_container").append('<li class="error_message">' + msg + '</li>');
|
||||
})
|
||||
$("#sf_msg_container").show();
|
||||
}
|
||||
}).always(function(r) {
|
||||
$('#sf-spinner-panel').css('width', '0%'); // Workaround for Safari issue
|
||||
});
|
||||
});
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
});
|
||||
inverterStringsPerInverter.val(inverterStringsPerInverterValue);
|
||||
inverterStringsPerInverterForm.css('display', 'inherit');
|
||||
inverterStringsPerInverterForm.css('display', 'block');
|
||||
} else {
|
||||
inverterStringsPerInverter.append($('<option selected value="0"></option>'));
|
||||
inverterStringsPerInverterForm.css('display', 'none');
|
||||
@@ -160,7 +160,8 @@
|
||||
if (data) {
|
||||
$('#standalone_inverter_id').val(uuid);
|
||||
$('#standalone_ac_run_length').val(data['ac_run_length']);
|
||||
$('#attachment-point').val(data['attachment_point'][0]);
|
||||
var attach_point = data['attachment_point'][1];
|
||||
$('#attachment_point option[value=' + attach_point + ']').attr('selected','selected');
|
||||
|
||||
fillInverterData(data, '#inverter');
|
||||
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
{% extends "layout.html.jinja" %}
|
||||
{% set title = "Helix Calculator" %}
|
||||
{% block contents %}
|
||||
<script>
|
||||
{%if context['corners'] and 'ff_cpp' is active_feature %}
|
||||
var corners_data = {{ context['corners']|tojson}};
|
||||
if (corners_data){
|
||||
console.log("Corners data :");
|
||||
console.log(corners_data);
|
||||
}
|
||||
{%endif%}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var is_csv_available = {{ context['csv_available']|tojson|safe }};
|
||||
</script>
|
||||
@@ -10,6 +20,16 @@
|
||||
<i class="icon-spin6 animate-spin"></i>
|
||||
</div>
|
||||
|
||||
{% if 'sf_session' in session %}
|
||||
<ul id="sf_msg_container" class="msg-container" style="display:none;">
|
||||
</ul>
|
||||
|
||||
<div id="sf-spinner-panel" class="spinner-panel">
|
||||
<p>Loading DXF file from Salesforce. Please wait, this may take a while.</p>
|
||||
<i class="icon-spin6 animate-spin"></i>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not context['csv_available'] %}
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
{{ form.csrf_token }}
|
||||
@@ -33,6 +53,11 @@
|
||||
<span id="error_message_txt" class="error_message centered_error">{{ field.errors[0] }}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if context['infinite_loop_detection_message'] %}
|
||||
<span id="error_message_txt_inf_loop" class="error_message centered_error">{{ context['infinite_loop_detection_message'] }}</span>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
{% extends "layout.html.jinja" %}
|
||||
{% set title = "Helix Calculator" %}
|
||||
{% block contents %}
|
||||
{% for warning in context['warning_messages'] %}
|
||||
<div class="summary_warning">{{ warning.value }}</div>
|
||||
{% endfor %}
|
||||
{% if 'sfdc_export_urls' in context %}
|
||||
{% if context['sfdc_export_error'] %}
|
||||
<div class="summary_warning" style="margin-top: 20px;">{{ context['sfdc_export_error'] }}</div>
|
||||
{% else %}
|
||||
<div class="msg-container">Documents exported to Salesforce successfully.</div>
|
||||
{% endif %}
|
||||
|
||||
<ul class="msg-container">
|
||||
{% if context['sfdc_export_urls']['dxfUrl'] %}
|
||||
<li><a href="{{ context['sfdc_export_urls']['dxfUrl'] }}">DXF file</a> (uploaded on Helix)</li>
|
||||
{% else %}
|
||||
<li><a href="{{ context['sfdc_export_urls']['dxfUrlFromSF'] }}">DXF file</a> (uploaded on Salesforce)</li>
|
||||
{% endif %}
|
||||
<li><a href="{{ context['sfdc_export_urls']['documentationUrl'] }}">Documentation file</a></li>
|
||||
<li><a href="{{ context['sfdc_export_urls']['bomCsvUrl'] }}">BOM CSV file</a></li>
|
||||
<li><a href="{{ context['sfdc_export_urls']['bomJsonUrl'] }}">BOM JSON file</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class="form_section">
|
||||
<h3>Download</h3>
|
||||
@@ -25,7 +40,7 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% if 'SFID' in session %}
|
||||
{% if 'sf_session' in session %}
|
||||
<div class="download">
|
||||
<a href="/export-sfdc">
|
||||
<button>Export documents to Salesforce</button>
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
<div>Inverter Brand</div>
|
||||
</div>
|
||||
<form name="inverter_brand_form" action="" method="post" enctype="multipart/form-data">
|
||||
<div id="inverter_brand_form"
|
||||
class="form_section ebom_form">
|
||||
<div id="inverter_brand_form" class="form_section ebom_form">
|
||||
{{ inverter_brand_form.csrf_token }}
|
||||
{% for field in inverter_brand_form.group('hidden') %}
|
||||
{{ field }}
|
||||
|
||||
@@ -59,7 +59,23 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<br>
|
||||
<div class="summary_warning">
|
||||
{% for message in messages %}
|
||||
<div>{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% block contents %}{% endblock %}
|
||||
|
||||
{% if 'sf_session' in session %}
|
||||
<small><i>Salesforce project</i> (<a href="/sales_force_logout">Log out</a>)</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
|
||||
|
||||
@@ -87,7 +87,4 @@
|
||||
|
||||
{% endif %}
|
||||
{% include "navigation_buttons.html.jinja" %}
|
||||
{% if 'SFID' in session %}
|
||||
<small><i>Sales Force project</i> (<a href="/sales_force_logout">Logout</a>)</small>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,13 +100,13 @@ class FileValidator(object):
|
||||
finally:
|
||||
return content
|
||||
|
||||
def validate(self, stream, file, expected):
|
||||
def validate(self, stream, expected, file=None, extension=None):
|
||||
"""Validates the uploaded file by extension
|
||||
and content
|
||||
|
||||
Arguments;
|
||||
stream (string): File content
|
||||
file (FileObject): A file object provided from the ui
|
||||
file (FileObject): A file object provided from the ui. Used only to get the file extension.
|
||||
|
||||
"""
|
||||
|
||||
@@ -114,7 +114,8 @@ class FileValidator(object):
|
||||
file_type = self.identify_file_type(stream)
|
||||
assert file_type == expected
|
||||
validator = file_type.validator(self.values)
|
||||
extension = self.obtain_extension(file)
|
||||
if extension is None:
|
||||
extension = self.obtain_extension(file)
|
||||
file_type.valid_mapping(extension)
|
||||
return validator.validate(stream)
|
||||
except AssertionError:
|
||||
|
||||
@@ -2,7 +2,7 @@ nose==1.3.7
|
||||
selenium==2.53.1
|
||||
splinter==0.7.3
|
||||
cssselect==0.9.1
|
||||
lxml==3.6.0
|
||||
lxml==4.1.1
|
||||
mockredispy==2.9.0.11
|
||||
Flask-Testing==0.4.2
|
||||
splinter[flask]
|
||||
|
||||
@@ -23,3 +23,5 @@ blinker==1.4
|
||||
Flask-OAuthlib==0.9.4
|
||||
boto3==1.4.8
|
||||
ujson==1.35
|
||||
Flask-FeatureFlags==0.6
|
||||
mock==2.0.0
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
python-3.5.1
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
from numpy.testing import assert_array_equal, assert_equal
|
||||
from helix.constants.module_type import ModuleType
|
||||
@@ -9,11 +10,15 @@ from helix.models.subarray import Subarray
|
||||
from helix.presenters.panel_presenter import ProjectPresenter
|
||||
from helix.constants.system_type import SystemType
|
||||
from helix.constants.panel_type import PanelType
|
||||
from test.test_helpers import feature_is_always_active
|
||||
import flask_featureflags
|
||||
|
||||
|
||||
flask_featureflags.is_active = feature_is_always_active
|
||||
|
||||
|
||||
class PanelPresenterTest(unittest.TestCase):
|
||||
|
||||
|
||||
def test_get_table_data_single_tilt_96cell(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
panels = [
|
||||
@@ -66,16 +71,81 @@ class PanelPresenterTest(unittest.TestCase):
|
||||
|
||||
def test_get_buildings_data(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ Coordinate(-60,-60), Coordinate(60,-60), Coordinate(60,60), Coordinate(-60,60) ] ] # big square
|
||||
buildings = [ [ Coordinate(0,0), Coordinate(60,0), Coordinate(60,60), Coordinate(0,60) ] ] # big square
|
||||
expected_buildings = [[
|
||||
{'x': -60, '_Coordinate__rounded_x': -60, 'y': -60, '_Coordinate__rounded_y': -60, 'rotation': 0.0},
|
||||
{'x': 60, '_Coordinate__rounded_x': 60, 'y': -60, '_Coordinate__rounded_y': -60, 'rotation': 0.0},
|
||||
{'x': 60, '_Coordinate__rounded_x': 60, 'y': 60, '_Coordinate__rounded_y': 60, 'rotation': 0.0},
|
||||
{'x': -60, '_Coordinate__rounded_x': -60, 'y': 60, '_Coordinate__rounded_y': 60, 'rotation': 0.0}
|
||||
{'x': 0, '_Coordinate__rounded_x': 0, 'y': 60, '_Coordinate__rounded_y': 0, 'rotation': 0.0},
|
||||
{'x': 60, '_Coordinate__rounded_x': 60, 'y': 60, '_Coordinate__rounded_y': 0, 'rotation': 0.0},
|
||||
{'x': 60, '_Coordinate__rounded_x': 60, 'y': 0, '_Coordinate__rounded_y': 60, 'rotation': 0.0},
|
||||
{'x': 0, '_Coordinate__rounded_x': 0, 'y': 0, '_Coordinate__rounded_y': 60, 'rotation': 0.0}
|
||||
]]
|
||||
actual_buildings = self.subject.get_buildings(buildings)
|
||||
actual_buildings = self.subject.get_buildings(buildings,60)
|
||||
assert_array_equal(actual_buildings,expected_buildings)
|
||||
|
||||
def test_get_corners_fancy_building(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ [2, 5], [2, 3], [0,3], [0, 0], [2,0], [2,-3], [6,-3], [8,-1], [8,1], [6,3], [4,3], [4,5] ] ] # fancy builgin with three interior corners
|
||||
expected_corners = [[
|
||||
{'length_ccw': 2.0, 'angle': 90.0, 'y': 5, 'x': 4, 'length_cw': 2.0},
|
||||
{'length_ccw': 2.0, 'angle': 90.0, 'y': 5, 'x': 2, 'length_cw': 2.0},
|
||||
{'length_ccw': 3.0, 'angle': 90.0, 'y': 3, 'x': 0, 'length_cw': 2.0},
|
||||
{'length_ccw': 2.0, 'angle': 90.0, 'y': 0, 'x': 0, 'length_cw': 3.0},
|
||||
{'length_ccw': 4.0, 'angle': 90.0, 'y': -3, 'x': 2, 'length_cw': 3.0}]]
|
||||
actual_corners = self.subject.get_corners(buildings)
|
||||
assert_array_equal(actual_corners,expected_corners)
|
||||
|
||||
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
|
||||
def test_get_corners_box_building(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ [0, 0], [60, 0], [60,60], [0, 60] ] ] # big square
|
||||
expected_corners = [[
|
||||
{'x': 0, 'y': 60, 'length_cw': 60, 'length_ccw':60, 'angle':90},
|
||||
{'x': 0, 'y': 0, 'length_cw': 60, 'length_ccw':60, 'angle':90},
|
||||
{'x': 60, 'y': 0, 'length_cw': 60, 'length_ccw':60, 'angle':90},
|
||||
{'x': 60, 'y': 60, 'length_cw': 60, 'length_ccw':60, 'angle':90}
|
||||
]]
|
||||
actual_corners = self.subject.get_corners(buildings)
|
||||
assert_array_equal(actual_corners,expected_corners)
|
||||
|
||||
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
|
||||
def test_get_corners_box_building_rotated_30_degrees(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ [0, 0], [51.96, 30], [21.96, 81.96], [-30, 51.96] ] ] # big square
|
||||
expected_corners = [[
|
||||
{'x': -30, 'y': 51.96, 'length_cw': 59.998679985479676, 'length_ccw':59.99867998547968, 'angle':90},
|
||||
{'x': 0, 'y': 0, 'length_cw': 59.99867998547968, 'length_ccw':59.99867998547968, 'angle':90},
|
||||
{'x': 51.96, 'y': 30, 'length_cw': 59.99867998547968, 'length_ccw':59.998679985479676, 'angle':90},
|
||||
{'x': 21.96, 'y': 81.96, 'length_cw': 59.998679985479676, 'length_ccw':59.998679985479676, 'angle':90.00000000000001}
|
||||
]]
|
||||
actual_corners = self.subject.get_corners(buildings)
|
||||
assert_array_equal(actual_corners,expected_corners)
|
||||
|
||||
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
|
||||
def test_get_corners_building(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ [-3.42, 1.51], [-1.66, -1.64], [4.22, -0.87], [-0.8, 5.64]] ]
|
||||
expected_corners = [[
|
||||
{'x': -0.8, 'y': 5.64, 'length_cw': 8.22073597678456, 'length_ccw':4.890940604832571, 'angle':70.02691327912069},
|
||||
{'x': -3.42, 'y': 1.51, 'length_cw': 4.890940604832571, 'length_ccw':3.6083375673570233, 'angle':118.41626123074676},
|
||||
{'x': -1.66, 'y': -1.64, 'length_cw': 3.6083375673570233, 'length_ccw':5.930202357424239, 'angle':111.73284308914216},
|
||||
{'x': 4.22, 'y': -0.87, 'length_cw': 5.930202357424239, 'length_ccw':8.22073597678456, 'angle':59.82398240099042}
|
||||
]]
|
||||
actual_corners = self.subject.get_corners(buildings)
|
||||
assert_array_equal(actual_corners,expected_corners)
|
||||
|
||||
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
|
||||
def test_get_corners_wild_building_with_big_angles(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
buildings = [ [ [-3.58, 3.32], [-0.78, -2.9], [-1.56,0.88], [0.66, -2.16], [1.5, 1.16], [2.72, 2.36], [-0.8, 5.64] ] ]
|
||||
expected_corners = [[
|
||||
{'x': -0.8, 'y': 5.64, 'length_cw': 4.811319985201567, 'length_ccw':3.6208838699963852, 'angle':97.17527350158385},
|
||||
{'x': -3.58, 'y': 3.32, 'length_cw': 3.6208838699963852, 'length_ccw':6.821172919667115, 'angle':105.6106862572924},
|
||||
{'x': -0.78, 'y': -2.9, 'length_cw': 6.821172919667115, 'length_ccw':3.8596372886580936, 'angle':12.576112527956782},
|
||||
{'x': 0.66, 'y': -2.16, 'length_cw': 3.7643060449437424, 'length_ccw':3.424616766880639, 'angle':50.337833086033},
|
||||
{'x': 2.72, 'y': 2.36, 'length_cw': 1.7112568480505783, 'length_ccw':4.811319985201567, 'angle':87.50512700090906}
|
||||
]]
|
||||
actual_corners = self.subject.get_corners(buildings)
|
||||
assert_array_equal(actual_corners,expected_corners)
|
||||
|
||||
def test_get_max_y(self):
|
||||
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
|
||||
panels = [
|
||||
|
||||
@@ -105,3 +105,7 @@ def assert_image_equal(image_1, image_2, error=5e-2):
|
||||
|
||||
average_error = total_error / pixels
|
||||
assert average_error <= error, "Images are not equal to within %f error (got %f)" % (error, average_error)
|
||||
|
||||
# used for mocking response of feature flags
|
||||
def feature_is_always_active(feature_name):
|
||||
return True
|
||||
|
||||
@@ -28,12 +28,12 @@ class FileValidatorTest(unittest.TestCase):
|
||||
with open('test/fixtures/input_single_tilt.csv', 'r',
|
||||
newline='') as file:
|
||||
cad_input = file.read()
|
||||
eq_(self.subject.validate(cad_input, fake_file, FileType.Csv), None)
|
||||
eq_(self.subject.validate(cad_input, FileType.Csv, fake_file), None)
|
||||
|
||||
def test_unknown_files_are_invalid(self):
|
||||
fake_file = MagicMock()
|
||||
type(fake_file).filename = PropertyMock(return_value="Hi")
|
||||
result = self.subject.validate("Hi", fake_file, FileType.Unknown)
|
||||
result = self.subject.validate("Hi", FileType.Unknown, fake_file)
|
||||
self.should_have_error(result,
|
||||
FileValidationMessage.UnknownFileUploaded, None)
|
||||
|
||||
@@ -62,8 +62,7 @@ class FileValidatorTest(unittest.TestCase):
|
||||
fake_file.read.return_value = open(fname, "rb").read()
|
||||
fake_file.filename.return_value = "expected_dual_tilt_pseries_image.png"
|
||||
stream = self.subject.obtain_stream(fake_file)
|
||||
self.should_have_error(self.subject.validate(stream, fake_file,
|
||||
FileType.AuroraDxf),
|
||||
self.should_have_error(self.subject.validate(stream, FileType.AuroraDxf, fake_file),
|
||||
FileValidationMessage.ExpectedDxfFile,
|
||||
None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user