Skip to content

Commit

Permalink
Refactor line length to 80
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Aug 1, 2021
1 parent 59379e7 commit b79a8f1
Show file tree
Hide file tree
Showing 28 changed files with 688 additions and 260 deletions.
3 changes: 2 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ We would like to develop in a positive environment so please try to:
* give constructive criticism and take it gracefully if given
* show empathy to others

We'll hope that this small guideline in combination with common sense will suffice.
We'll hope that this small guideline in combination with common sense will
suffice.

If you have questions feel free to contact us at <[email protected]>
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# How to contribute

Thank you for thinking about to contribute to OpenAtlas and reading this document.
Thank you for thinking about to contribute to OpenAtlas and reading this
document.

We are happy about participation and there are multiple ways to contribute.

Expand All @@ -14,8 +15,8 @@ reading our [How to report an issue](https://redmine.openatlas.eu/projects/uni/w

## Code contribution

We also welcome code contributions e.g. via a Git pull request.
We also welcome code contributions e.g. via a GitHub pull requests.

Please be sure to read our
[Development Standards](https://redmine.openatlas.eu/projects/uni/wiki/Standards)
to avoid unnessacery complications.
to avoid complications.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# About

[OpenAtlas](https://openatlas.eu) is an open source, web based database system for
complex archaeological, historical and prosopographical data.
[OpenAtlas](https://openatlas.eu) is an open source, web based database system
for complex archaeological, historical and prosopographical data.

The information is mapped as a network using classes and properties of the [CIDOC CRM](http://www.cidoc-crm.org/).
The information is mapped as a network using classes and properties of the
[CIDOC CRM](http://www.cidoc-crm.org/).

Documentation:
[Manual](https://demo.openatlas.eu/static/manual/),
Expand All @@ -12,19 +13,23 @@ Documentation:

# Demo versions

[Demo](https://demo.openatlas.eu) with data kindly provided by the [MEDCON](https://oeaw.academia.edu/MappingMedievalConflict) project.
[Demo](https://demo.openatlas.eu) with data kindly provided by the
[MEDCON](https://oeaw.academia.edu/MappingMedievalConflict) project.

[Development demo](https://demo-dev.openatlas.eu) with data kindly provided by the [DPP](https://dpp.oeaw.ac.at/) project.
[Development demo](https://demo-dev.openatlas.eu) with data kindly provided by
the [DPP](https://dpp.oeaw.ac.at/) project.

# Installation

Please refer to [install.md](install.md) for requirements and installation.

# Team

**Stefan Eichert** - Idea, Concept and Data Modelling ([[email protected]](mailto:[email protected]))
**Stefan Eichert** - Idea, Concept and Data Modelling
([[email protected]](mailto:[email protected]))

**Alexander Watzinger** - Lead Developer and Concept ([[email protected]](mailto:[email protected]))
**Alexander Watzinger** - Lead Developer and Concept
([[email protected]](mailto:[email protected]))

**Bernhard Koschiček-Krombholz** - Software Development

Expand All @@ -36,7 +41,10 @@ Please refer to [install.md](install.md) for requirements and installation.

# Licensing

All OpenAtlas code unless otherwise noted is licensed under the terms of the GNU General Public License Version 2,
June 1991. Please refer to the file COPYING in the root directory of this repository or the online version at <https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html>
All OpenAtlas code unless otherwise noted is licensed under the terms of the
GNU General Public License Version 2, June 1991. Please refer to the file
COPYING in the root directory of this repository or the online version at
<https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html>

The OpenAtlas logo was designed by Jan Belik and is licensed under [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
The OpenAtlas logo was designed by Jan Belik and is licensed under
[CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
27 changes: 19 additions & 8 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ def setUp(self) -> None:
app.testing = True
app.config['SERVER_NAME'] = 'local.host'
app.config['WTF_CSRF_ENABLED'] = False
app.config['WTF_CSRF_METHODS'] = [] # This is the magic to disable CSRF for tests
app.config['WTF_CSRF_METHODS'] = [] # Disable CSRF in tests

self.setup_database()
self.app = app.test_client()
self.login() # Login on default because needed almost everywhere
with app.app_context(): # type: ignore
self.app.get('/') # Needed to get fieldnames below, to initialise g or something
self.app.get('/') # Needed to initialise g
self.precision_geonames = \
'reference_system_precision_' + str(ReferenceSystem.get_by_name('GeoNames').id)
'reference_system_precision_' + \
str(ReferenceSystem.get_by_name('GeoNames').id)
self.precision_wikidata = \
'reference_system_precision_' + str(ReferenceSystem.get_by_name('Wikidata').id)
'reference_system_precision_' + \
str(ReferenceSystem.get_by_name('Wikidata').id)

def login(self) -> None:
with app.app_context(): # type: ignore
self.app.post('/login', data={'username': 'Alice', 'password': 'test'})
self.app.post(
'/login',
data={'username': 'Alice', 'password': 'test'})

@staticmethod
def setup_database() -> None:
Expand All @@ -41,9 +45,16 @@ def setup_database() -> None:
port=app.config['DATABASE_PORT'])
connection.autocommit = True
cursor = connection.cursor()
for file_name in ['1_structure', '2_data_model', '3_data_web', '4_data_node', 'data_test']:
with open(pathlib.Path(app.root_path).parent / 'install' / (file_name + '.sql'),
encoding='utf8') as sql_file:
for file_name in [
'1_structure',
'2_data_model',
'3_data_web',
'4_data_node',
'data_test']:
with open(
pathlib.Path(app.root_path).parent / 'install' /
(file_name + '.sql'),
encoding='utf8') as sql_file:
cursor.execute(sql_file.read())


Expand Down
31 changes: 23 additions & 8 deletions tests/test_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def test_actor(self) -> None:
# Actor insert
rv = self.app.get(url_for('insert', class_='person'))
assert b'+ Person' in rv.data
self.app.get(url_for('insert', class_='person', origin_id=residence_id))
self.app.get(
url_for('insert', class_='person', origin_id=residence_id))
data = {
sex_node.id: sex_node_sub_1.id,
'name': 'Sigourney Weaver',
Expand Down Expand Up @@ -57,7 +58,8 @@ def test_actor(self) -> None:
# Test actor nodes
rv = self.app.get(url_for('entity_view', id_=sex_node_sub_1.id))
assert b'Susan' in rv.data
rv = self.app.get(url_for('node_move_entities', id_=sex_node_sub_1.id))
rv = self.app.get(
url_for('node_move_entities', id_=sex_node_sub_1.id))
assert b'Sigourney' in rv.data
rv = self.app.post(
url_for('node_move_entities', id_=sex_node_sub_1.id),
Expand All @@ -70,11 +72,20 @@ def test_actor(self) -> None:
rv = self.app.post(
url_for('node_move_entities', id_=sex_node_sub_2.id),
follow_redirects=True,
data={sex_node.id: '', 'selection': [actor_id], 'checkbox_values': str([actor_id])})
data={
sex_node.id: '',
'selection': [actor_id],
'checkbox_values': str([actor_id])})
assert b'Entities were updated' in rv.data
self.app.post(url_for('insert', class_='person', origin_id=actor_id), data=data)
self.app.post(url_for('insert', class_='person', origin_id=event.id), data=data)
self.app.post(url_for('insert', class_='person', origin_id=source.id), data=data)
self.app.post(
url_for('insert', class_='person', origin_id=actor_id),
data=data)
self.app.post(
url_for('insert', class_='person', origin_id=event.id),
data=data)
self.app.post(
url_for('insert', class_='person', origin_id=source.id),
data=data)
rv = self.app.post(
url_for('insert', class_='external_reference'),
data={'name': 'https://openatlas.eu'})
Expand Down Expand Up @@ -119,7 +130,10 @@ def test_actor(self) -> None:
data['end_year_to'] = ''
data['begin_year_to'] = '1950'
data['begin_day_from'] = ''
rv = self.app.post(url_for('update', id_=actor_id), data=data, follow_redirects=True)
rv = self.app.post(
url_for('update', id_=actor_id),
data=data,
follow_redirects=True)
assert b'Changes have been saved' in rv.data
rv = self.app.post(
url_for('ajax_bookmark'),
Expand All @@ -139,5 +153,6 @@ def test_actor(self) -> None:
assert b'removed' in rv.data

# Actor delete
rv = self.app.get(url_for('index', view='actor', delete_id=actor_id))
rv = self.app.get(
url_for('index', view='actor', delete_id=actor_id))
assert b'The entry has been deleted.' in rv.data
5 changes: 3 additions & 2 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_orphans_and_newsletter(self) -> None:
self.precision_wikidata: ''})
with app.test_request_context():
app.preprocess_request() # type: ignore
Entity.insert('file', 'One forsaken file entity') # Add orphaned file
Entity.insert('file', 'One forsaken file entity')
rv = self.app.get(url_for('admin_orphans'))
assert all(x in rv.data for x in [b'Oliver Twist', b'forsaken'])
rv = self.app.get(url_for('admin_newsletter'))
Expand All @@ -29,7 +29,8 @@ def test_logs(self) -> None:
with app.app_context(): # type: ignore
rv = self.app.get(url_for('admin_log'))
assert b'Login' in rv.data
rv = self.app.get(url_for('admin_log_delete', follow_redirects=True))
rv = self.app.get(
url_for('admin_log_delete', follow_redirects=True))
assert b'Login' not in rv.data

def test_links(self) -> None:
Expand Down
10 changes: 7 additions & 3 deletions tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def test_artifact(self) -> None:
rv = self.app.post(
url_for('update', id_=artifact.id),
follow_redirects=True,
data={'name': 'A little hate', 'description': 'makes nothing better'})
data={
'name': 'A little hate',
'description': 'makes nothing better'})
assert b'Changes have been saved' in rv.data

# Add to artifact
Expand All @@ -43,15 +45,17 @@ def test_artifact(self) -> None:
assert b'Necronomicon' in rv.data

# Add to event
rv = self.app.get(url_for('insert', class_='move', origin_id=artifact.id))
rv = self.app.get(
url_for('insert', class_='move', origin_id=artifact.id))
assert b'A little hate' in rv.data
rv = self.app.post(
url_for('insert', class_='move', origin_id=artifact.id),
data={'name': 'Event Horizon', 'artifact': [artifact.id]},
follow_redirects=True)
assert b'Event Horizon' in rv.data

rv = self.app.get(url_for('index', view='artifact', delete_id=artifact.id))
rv = self.app.get(
url_for('index', view='artifact', delete_id=artifact.id))
assert b'has been deleted' in rv.data

# Insert and continue
Expand Down
38 changes: 30 additions & 8 deletions tests/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,56 @@ def test_date(self) -> None:
# Dates insert (don't change year values - they test leap years too)
data = {
'name': 'Date place',
'begin_year_from': -1949, 'begin_month_from': 2, 'begin_day_from': 8,
'begin_year_to': -1948, 'end_year_from': 1996, 'end_year_to': 1996,
'begin_year_from': -1949,
'begin_month_from': 2,
'begin_day_from': 8,
'begin_year_to': -1948,
'end_year_from': 1996,
'end_year_to': 1996,
self.precision_geonames: '',
self.precision_wikidata: ''}
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'Date place' in rv.data

# Invalid dates
data['begin_day_from'] = 31
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'Not a valid date' in rv.data

# Invalid time span (first after second date)
data['begin_day_from'] = 5
data['begin_year_from'] = 20
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'First date cannot be after second' in rv.data

# Invalid begin dates which are after end dates
data['begin_year_from'] = -1949
data['end_year_from'] = -2000
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'Begin dates cannot start after end dates' in rv.data
data['end_year_to'] = ''
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'Begin dates cannot start after end dates' in rv.data

# Missing form fields
data['begin_year_from'] = ''
rv = self.app.post(url_for('insert', class_='place'), data=data, follow_redirects=True)
rv = self.app.post(
url_for('insert', class_='place'),
data=data,
follow_redirects=True)
assert b'Required for time span' in rv.data
Loading

0 comments on commit b79a8f1

Please sign in to comment.