Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
78f094a8df
@ -95,7 +95,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
images_files = forms.ModelMultipleChoiceField(
|
images_files = forms.ModelMultipleChoiceField(
|
||||||
queryset=ImageFile.objects.all(),
|
queryset=ImageFile.objects.all(),
|
||||||
widget=CommaSeparatedTextInput(),
|
widget=CommaSeparatedTextInput(),
|
||||||
required=True
|
required=False
|
||||||
)
|
)
|
||||||
|
|
||||||
official_project_documents = forms.FileField(
|
official_project_documents = forms.FileField(
|
||||||
|
@ -87,6 +87,78 @@ class MapTest(SeleniumTest):
|
|||||||
)
|
)
|
||||||
self.case_study.save()
|
self.case_study.save()
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
self.user = User.objects.create_superuser(username='test', password='test', email='test@example.com');
|
||||||
|
self.sl.find_element_by_id('id_username').send_keys('test');
|
||||||
|
self.sl.find_element_by_id('id_password').send_keys('test');
|
||||||
|
self.sl.find_element_by_css_selector('input[type="submit"]').click()
|
||||||
|
|
||||||
|
def place_marker(self):
|
||||||
|
# click the zoom out button enough to bring up the thing to draw marker then use it.
|
||||||
|
# the headless browser needs time between each click or it does not show the draw-marker control.
|
||||||
|
for i in range(0, 15):
|
||||||
|
self.sl.find_element_by_class_name('leaflet-control-zoom-in').click()
|
||||||
|
time.sleep(0.2)
|
||||||
|
self.sl.find_element_by_class_name('leaflet-draw-draw-marker').click()
|
||||||
|
self.sl.find_element_by_id('id_location-map').click()
|
||||||
|
|
||||||
|
def test_form_will_show_error(self):
|
||||||
|
self._open('/en-gb/case-study/create/long');
|
||||||
|
self.login();
|
||||||
|
# navigate to the last tab, where the submit button is
|
||||||
|
self.sl.find_element_by_css_selector('a[href="#uploads"]').click()
|
||||||
|
# click submit without filling in any fields
|
||||||
|
self.sl.find_element_by_id('submit-id-submit').click()
|
||||||
|
error_message = self.sl.find_element_by_class_name('has-error')
|
||||||
|
self.assertTrue(error_message.is_displayed())
|
||||||
|
|
||||||
|
def test_short_form_will_submit(self):
|
||||||
|
self._open('/en-gb/case-study/create/short');
|
||||||
|
self.login()
|
||||||
|
self.place_marker()
|
||||||
|
self.sl.find_element_by_id('id_entry_name').send_keys('Short Entry');
|
||||||
|
Select(self.sl.find_element_by_id('id_country')).select_by_visible_text('Albania');
|
||||||
|
self.sl.find_element_by_id('id_area_of_land').send_keys('123');
|
||||||
|
Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private Land');
|
||||||
|
Select(self.sl.find_element_by_id('id_location_context')).select_by_visible_text('Urban');
|
||||||
|
self.sl.find_element_by_id('id_describe_ecosystem').send_keys('test');
|
||||||
|
Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('Existing Project');
|
||||||
|
Select(self.sl.find_element_by_id('id_sector_of_economy')).select_by_visible_text('Power Grids');
|
||||||
|
self.sl.find_element_by_id('id_synopsis').send_keys('test');
|
||||||
|
self.sl.find_element_by_id('id_full_description').send_keys('test');
|
||||||
|
Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('Positive');
|
||||||
|
# you can submit the form on any field. Using this one because the submit button sometimes isn't visible
|
||||||
|
self.sl.find_element_by_id('id_area_of_land').submit();
|
||||||
|
self.assertTrue("Thanks!" in self.sl.page_source, "Success message not shown")
|
||||||
|
self._open('/admin/map/casestudy/');
|
||||||
|
self.assertTrue("Short Entry" in self.sl.page_source, "Case study not saved")
|
||||||
|
|
||||||
|
def test_long_form_will_submit(self):
|
||||||
|
self._open('/en-gb/case-study/create/long');
|
||||||
|
self.login()
|
||||||
|
self.place_marker()
|
||||||
|
self.sl.find_element_by_id('id_entry_name').send_keys('Long Entry');
|
||||||
|
Select(self.sl.find_element_by_id('id_country')).select_by_visible_text('Albania');
|
||||||
|
self.sl.find_element_by_id('id_area_of_land').send_keys('123');
|
||||||
|
Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private Land');
|
||||||
|
Select(self.sl.find_element_by_id('id_location_context')).select_by_visible_text('Urban');
|
||||||
|
self.sl.find_element_by_id('id_describe_ecosystem').send_keys('test');
|
||||||
|
Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('Existing Project');
|
||||||
|
self.sl.find_element_by_id('id_synopsis').send_keys('test');
|
||||||
|
self.sl.find_element_by_id('id_full_description').send_keys('test');
|
||||||
|
self.sl.find_element_by_id('id_project_owners').send_keys('test');
|
||||||
|
self.sl.find_element_by_id('id_shareholders').send_keys('test');
|
||||||
|
self.sl.find_element_by_css_selector('a[href="#technical-and-economic-analysis"]').click()
|
||||||
|
Select(self.sl.find_element_by_id('id_sector_of_economy')).select_by_visible_text('Power Grids');
|
||||||
|
self.sl.find_element_by_css_selector('a[href="#socio-environmental-analysis"]').click()
|
||||||
|
Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('Positive');
|
||||||
|
self.sl.find_element_by_css_selector('a[href="#uploads"]').click()
|
||||||
|
# you can submit the form on any field. Using this one because the submit button sometimes isn't visible
|
||||||
|
self.sl.find_element_by_id('id_name_of_territory_or_area').submit();
|
||||||
|
self.assertTrue("Thanks!" in self.sl.page_source, "Success message not shown")
|
||||||
|
self._open('/admin/map/casestudy/');
|
||||||
|
self.assertTrue("Long Entry" in self.sl.page_source, "Case study not saved")
|
||||||
|
|
||||||
def test_map(self):
|
def test_map(self):
|
||||||
self._open('/')
|
self._open('/')
|
||||||
WebDriverWait(self.sl, 5).until(
|
WebDriverWait(self.sl, 5).until(
|
||||||
|
Loading…
Reference in New Issue
Block a user