Skip to content
Snippets Groups Projects
Commit 0a90b976 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Fix tests now that services aren't part of publisher

parent e337bb36
No related branches found
No related tags found
No related merge requests found
import csv
import os
import random
import json
import compendium_v2
import pytest
from compendium_v2.auth.session_management import setup_login_manager, User, ROLES
......@@ -12,9 +12,13 @@ from flask_login import LoginManager # type: ignore
from sqlalchemy import select
def _test_data_csv(filename):
def _test_data(filename, as_csv=True):
data_filename = os.path.join(os.path.dirname(__file__), 'data', filename)
yield from csv.DictReader(open(data_filename, "r"))
if not as_csv:
return open(data_filename, "r")
return csv.DictReader(open(data_filename, "r"))
@pytest.fixture
......@@ -26,6 +30,20 @@ def dummy_config():
}
def nren_services():
with _test_data('service-matrix-services.json', as_csv=False) as f:
services = json.load(f)
for name_key, record in services.items():
service = presentation_models.Service(
name_key=name_key,
name=record['name'],
category=record['category'],
description=record['description'],
)
db.session.merge(service)
db.session.commit()
@pytest.fixture
def mocked_admin_user(app, test_survey_data, mocker):
with app.app_context():
......@@ -77,7 +95,7 @@ def mocked_observer_user(app, test_survey_data, mocker):
@pytest.fixture
def test_budget_data(app):
with app.app_context():
data = [row for row in _test_data_csv("BudgetTestData.csv")]
data = [row for row in _test_data("BudgetTestData.csv")]
nren_names = set([row["nren"] for row in data])
nren_dict = {nren_name: presentation_models.NREN(name=nren_name, country='country') for nren_name in nren_names}
db.session.add_all(nren_dict.values())
......@@ -94,7 +112,7 @@ def test_budget_data(app):
@pytest.fixture
def test_funding_source_data(app):
with app.app_context():
data = [row for row in _test_data_csv("FundingSourceTestData.csv")]
data = [row for row in _test_data("FundingSourceTestData.csv")]
nren_names = set([row["nren"] for row in data])
nren_dict = {nren_name: presentation_models.NREN(name=nren_name, country='country') for nren_name in nren_names}
db.session.add_all(nren_dict.values())
......@@ -237,8 +255,10 @@ def app(dummy_config):
login_manager.init_app(app)
login_manager.login_view = 'authentication.login'
setup_login_manager(login_manager)
with app.app_context():
db.create_all(bind_key=None)
nren_services()
yield app
......@@ -248,6 +268,7 @@ def app_with_survey_db(dummy_config):
app = compendium_v2._create_app_with_db(dummy_config)
with app.app_context():
db.create_all()
nren_services()
yield app
......@@ -259,7 +280,7 @@ def client(app):
@pytest.fixture
def test_charging_structure_data(app):
with app.app_context():
data = [row for row in _test_data_csv("ChargingStructureTestData.csv")]
data = [row for row in _test_data("ChargingStructureTestData.csv")]
nren_names = set([row["nren"] for row in data])
nren_dict = {nren_name: presentation_models.NREN(name=nren_name, country='country') for nren_name in nren_names}
db.session.add_all(nren_dict.values())
......
{
"anti-spam": {
"name": "Anti-spam solution",
"category": "security",
"description": "Anti-spam solutions for detecting and eliminating viruses and spam mails."
},
"class-registration": {
"name": "Class registration tool",
"category": "collaboration",
"description": "Software for teachers to register students for classes etc."
},
"cloud-service-end-user": {
"name": "Cloud storage (end user)",
"category": "storage_and_hosting",
"description": "Browser based virtual storage service for individuals."
},
"connectivity": {
"name": "IP connectivity",
"category": "network_services",
"description": "Basic IP connectivity services inc. R+E and commodity internet"
},
"consultancy": {
"name": "Consultancy/training",
"category": "professional_services",
"description": "Training and consultancy services provided by the NREN."
},
"content-delivery-hosting": {
"name": "Content delivery hosting",
"category": "storage_and_hosting",
"description": "Hosting of content delivery servers e.g. Akamai."
},
"content-management-system": {
"name": "CMS",
"category": "collaboration",
"description": "Provision of software systems for website authoring, collaboration and administration tools."
},
"csirt": {
"name": "CERT/CSIRT",
"category": "security",
"description": "A single point of contact for users to deal with computer security incidents and prevention."
},
"ddos-prevention": {
"name": "DDos mitigation",
"category": "security",
"description": "Tools and techniques for mitigating Distributed Denial of Service attacks."
},
"domain-registration": {
"name": "Domain name registration",
"category": "isp_support",
"description": "Administration/registration of top and second level domain names."
},
"eduroam-wifi": {
"name": "eduroam",
"category": "identity",
"description": "Inter-WLAN service to facilitate easy and secure Internet access for roaming educational users."
},
"email-services": {
"name": "Email server hosting",
"category": "collaboration",
"description": "NREN hosted email servers."
},
"filesender": {
"name": "FileSender",
"category": "storage_and_hosting",
"description": "Web based application that allows authenticated users to securely and easily send arbitrarily large files."
},
"firewall-on-demand": {
"name": "Firewall-On-Demand",
"category": "security",
"description": "Provision of a dynamic firewall services to mitigate against DDOS attacks. "
},
"home-vpn": {
"name": "Remote access VPN service",
"category": "network_services",
"description": "Remote access and site-to-site secure VPN."
},
"aai": {
"name": "Hosted campus AAI",
"category": "identity",
"description": "Hosting of an Identity Provider service on behalf of connected institutions to authenticate users."
},
"instant-messaging": {
"name": "Instant messaging",
"category": "collaboration",
"description": "Commercial or NREN own online chat service which offers real-time text transmission over the Internet."
},
"interfederation": {
"name": "Interfederation",
"category": "identity",
"description": "Participation in an inter-federation (i.e. eduGAIN, KALMAR)."
},
"internet-radio-tv": {
"name": "TV/radio streaming",
"category": "multimedia",
"description": "Internet and radio streaming services."
},
"internship-database": {
"name": "Database services",
"category": "collaboration",
"description": "Provision of tools or services to create or host databases."
},
"ip-address-allocation": {
"name": "IP address allocation/LIR",
"category": "isp_support",
"description": "Local Internet Registry service for assigning of IP address space."
},
"ipv6": {
"name": "IPv6",
"category": "network_services",
"description": "The new version of the Internet Protocol (IP) that should eventually replace the current IP (version 4)."
},
"ix-operation": {
"name": "National IX operation",
"category": "isp_support",
"description": "Operation of a national Internet Exchange."
},
"journal-library-access": {
"name": "Journal access",
"category": "collaboration",
"description": "Access to academic journals."
},
"dedicated-optical-connections": {
"name": "Dedicated Optical Connections",
"category": "network_services",
"description": "Provision of dedicated optical connections for users to connect to other parties."
},
"mailing-lists": {
"name": "Mailing lists",
"category": "collaboration",
"description": "Service for operation of electronic discussion lists."
},
"mobile-data": {
"name": "3G/4G data service",
"category": "network_services",
"description": "Provision of mobile broadband and phone contracts to users."
},
"multicast": {
"name": "Multicast",
"category": "network_services",
"description": "Extension to the IP protocol which allows individual packets to be sent to multiple hosts on the Internet."
},
"news-service": {
"name": "Netnews/USENET service",
"category": "storage_and_hosting",
"description": "Netnews/USENET news feed service."
},
"online-payment": {
"name": "Online payment connectivity",
"category": "identity",
"description": "Connectivity for chip and pin payment terminals."
},
"pert": {
"name": "PERT",
"category": "network_services",
"description": "Team supporting resolution of end-to-end performance problems for networked applications."
},
"plagarism-detection": {
"name": "Plagarism detection",
"category": "collaboration",
"description": "Provision of software for use by teachers etc to detect plagarism."
},
"point-to-point-circuit-vpn": {
"name": "Virtual circuit/VPN",
"category": "network_services",
"description": "Virtual point to point circuits or VPNs delivered as a service to users."
},
"procurement": {
"name": "Procurement/brokerage",
"category": "professional_services",
"description": "Procurement services, inc. negotiating agreements and framework agreements."
},
"project-collaboration-toolkit": {
"name": "Project collaboration tools",
"category": "collaboration",
"description": "Packaged services for virtual project groups e.g. mailing lists, storage, web meetings, wiki."
},
"quality-of-service": {
"name": "Quality of Service",
"category": "network_services",
"description": "Preferential service to specific applications or classes of applications."
},
"scheduling-tool": {
"name": "Scheduling tool",
"category": "collaboration",
"description": "Provision of tools to users for scheduling appointments or classes."
},
"sdn-testbed": {
"name": "SDN testbed",
"category": "network_services",
"description": "Software defined networking testbed available to users."
},
"sms-messaging": {
"name": "SMS messaging",
"category": "collaboration",
"description": "Service for users to send or receive SMS message by email."
},
"software-development": {
"name": "Software development",
"category": "professional_services",
"description": "Software development service for users."
},
"software-licenses": {
"name": "Software licenses",
"category": "professional_services",
"description": "Provision of software for organisational or institutional purchase."
},
"storage-co-location": {
"name": "Housing/co-location",
"category": "storage_and_hosting",
"description": "Hosting of user equipment in a managed data centre."
},
"survey-tool": {
"name": "Survey/polling tool",
"category": "collaboration",
"description": "Provision of applications for creating surveys or polls."
},
"system-backup": {
"name": "Hot standby",
"category": "storage_and_hosting",
"description": "Failover protection for primary web servers."
},
"timeserver-ntp": {
"name": "NTP service",
"category": "isp_support",
"description": "Allows the synchronization of computer clocks over the Internet."
},
"video-portal": {
"name": "Provision of content portal/s to users for hosting and viewing multi-media content",
"category": "multimedia",
"description": "Multi-media content portal"
},
"videoconferencing": {
"name": "Event recording/streaming",
"category": "multimedia",
"description": "Provision of equipment and/or software to support event streaming/recording."
},
"virtual-learning-environment": {
"name": "VLE",
"category": "collaboration",
"description": "Online e-learning education system that provides virtual access to resources used in teaching.."
},
"virtual-machines-iaas": {
"name": "Virtual machines/IaaS",
"category": "storage_and_hosting",
"description": "Access to virtual computing resources."
},
"voip": {
"name": "VoIP",
"category": "collaboration",
"description": "Service to deliver voice communications and multimedia sessions over Internet Protocol (IP) networks."
},
"vulnerability-testing": {
"name": "Vulnerability scanning",
"category": "security",
"description": "Vulnerability service that allows users to scan their own IP networks for security holes."
},
"web-conferencing": {
"name": "Web/desktop conferencing",
"category": "multimedia",
"description": "Video conferencing service to desktops and hand-held devices using software."
},
"web-design-production": {
"name": "Web development",
"category": "professional_services",
"description": "Web development service provided to NREN users."
},
"web-email-hosting": {
"name": "Web hosting",
"category": "storage_and_hosting",
"description": "Service to provide space on central web servers for users to publish their website."
},
"dns-server": {
"name": "DNS hosting",
"category": "storage_and_hosting",
"description": "Hosting of primary and secondary DNS servers."
},
"dissemination": {
"name": "Dissemination",
"category": "professional_services",
"description": "Dissemination of information to users e.g. newsletters and magazines."
},
"network-monitoring": {
"name": "Network monitoring",
"category": "network_services",
"description": "Network information system that shows the current and past performance of the network."
},
"disaster-recovery": {
"name": "Disaster recovery",
"category": "storage_and_hosting",
"description": "Off site backup services."
},
"user-monitoring": {
"name": "Network troubleshooting",
"category": "network_services",
"description": "Enables users at connected institutions to monitor Internet services in real time."
},
"netflow": {
"name": "Netflow tool",
"category": "network_services",
"description": "Network protocol for collecting IP traffic information and monitoring network traffic."
},
"managed-router": {
"name": "Managed router service",
"category": "network_services",
"description": "Remote network router support to institutions."
},
"intrusion": {
"name": "Intrusion detection",
"category": "security",
"description": "Systems for detecting and preventing Intrusions (IDS/IPS)."
},
"security-audit": {
"name": "Security auditing",
"category": "security",
"description": "Carrying out vulnerability assesments and security reviews of user systems and resources on their behalf."
},
"web-filtering": {
"name": "Web filtering",
"category": "security",
"description": "Centralised web content filtering service for protection against access to inappropriate content."
},
"pgp-key": {
"name": "PGP key server",
"category": "security",
"description": "Operation of PGP key server."
},
"identifier-reg": {
"name": "Identifier registry",
"category": "security",
"description": "Registering of unique and automatically-processable identifiers in the form of text or numeric strings."
},
"post-production": {
"name": "Media post production",
"category": "multimedia",
"description": "Work undertaken after the process of recording (or production) e.g. editing, synchronisation."
},
"e-portfolio": {
"name": "e-portfolio service",
"category": "collaboration",
"description": "Functions to create and share user professional and career e-portfolios."
},
"user-conference": {
"name": "User conferences",
"category": "professional_services",
"description": "Hosting of regular user conferences."
},
"user-portal": {
"name": "User portals",
"category": "professional_services",
"description": "User portal for service management and monitoring."
},
"admin-tools": {
"name": "Finance/admin systems",
"category": "professional_services",
"description": "Provision of ICT systems used in finance and administration."
},
"nameserver": {
"name": "Nameserver services",
"category": "isp_support",
"description": "Operation of nameservers and maintenance of DNS information on behalf of users."
},
"saas": {
"name": "SaaS",
"category": "storage_and_hosting",
"description": "Software as a service e.g. GoogleApps for Education."
}
}
\ No newline at end of file
......@@ -80,7 +80,7 @@ def test_load_service_data():
assert len(service_data_dict['ARNES'].keys()) == 8
assert len(service_data_dict['ARNES']['services_identity']) == 3
assert len(service_data_dict['SURF'].keys()) == 7
assert len(service_data_dict['SURF']['services_network']) == 10
assert len(service_data_dict['SURF']['services_network']) > 1
assert service_data_dict['SURF']['services_security']['security-audit'] == {
'offered': ['yes'],
'name': 'SURFaudit',
......
......@@ -106,7 +106,7 @@ def test_excel_publisher(app_with_survey_db, mocker):
== 'Institute for Informatics and Automation Problems of the National Academy of Sciences of Armenia'
service_data = db.session.scalars(select(presentation_models.Service)).all()
assert len(service_data) == 74
assert len(service_data) > 70
nren_service_data = db.session.scalars(select(presentation_models.NRENService)).all()
# test a random entry
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment