Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pyotp = "*"
pyjwt = "*"

[scripts]
test = "pytest"
test = "python -m pytest"
server = "python application.py"
schema-export = "python schema_export.py"
db-init = 'python manage.py db init'
Expand Down
7 changes: 0 additions & 7 deletions api/tests/test_auth_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
import os
from os.path import dirname, join, expanduser, normpath, realpath
from flask_bcrypt import Bcrypt

import pytest

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from models import Users, User_affiliations, Organizations
Expand Down
8 changes: 0 additions & 8 deletions api/tests/test_auth_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@
from flask_bcrypt import Bcrypt
from flask import Request
from werkzeug.test import create_environ

import pytest
from unittest import TestCase

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from queries import schema
from models import Users, User_affiliations, Organizations
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def user_role_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
10 changes: 0 additions & 10 deletions api/tests/test_cost_check.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from graphene.test import Client

from werkzeug.test import create_environ
from flask import Request
from flask_bcrypt import Bcrypt

from unittest import TestCase

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from db import db_session
from app import app
from queries import schema
from models import Users
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def user_schema_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
9 changes: 0 additions & 9 deletions api/tests/test_db_migrate.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest

from sqlalchemy import create_engine

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import *
from db import db_session, Base, engine


class TestDBCreation:
def test_created_schema_contains_expected_tables(self):
"""This test determines that the postgres db is created with the expected tables"""
Expand Down
10 changes: 0 additions & 10 deletions api/tests/test_depth_check.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

from werkzeug.test import create_environ
from flask import Request

import pytest
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from queries import schema
from models import Users
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def user_schema_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
15 changes: 2 additions & 13 deletions api/tests/test_domains_mutations.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from queries import schema
from backend.security_check import SecurityAnalysisBackend
from db import db_session
from models import (
Organizations,
Expand All @@ -32,10 +25,6 @@
Ssl_scans
)

from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def domain_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
10 changes: 0 additions & 10 deletions api/tests/test_domains_resolver_access_control.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from models import Organizations, Domains, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def domain_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
13 changes: 2 additions & 11 deletions api/tests/test_domains_resolver_values.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from queries import schema
from backend.security_check import SecurityAnalysisBackend
from models import (
Organizations,
Domains,
Expand All @@ -32,8 +25,6 @@
Spf_scans,
Ssl_scans
)
from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
Expand Down
14 changes: 2 additions & 12 deletions api/tests/test_email_address_scalar.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os

import pytest
from graphene.test import Client
from graphql import GraphQLScalarType
from graphql.language import ast
from graphql import GraphQLError

import unittest

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(
os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

from unittest import TestCase
from scalars.email_address import (
EmailAddress,
scalar_error_type,
scalar_error_only_types
)


class TestEmailAddressScalar(unittest.TestCase):
class TestEmailAddressScalar(TestCase):

def test_valid_email_serialize(self):
test_email = 'test.account@canada.ca'
Expand Down
8 changes: 0 additions & 8 deletions api/tests/test_notification_emails.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import os
import sys
from os.path import dirname, join, expanduser, normpath, realpath

from graphene.test import Client

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from functions.email_templates import (
email_verification_template,
password_reset_template)
from functions.error_messages import scalar_error_type
from app import app

from queries import schema
from backend.security_check import SecurityAnalysisBackend

Expand Down
13 changes: 2 additions & 11 deletions api/tests/test_organization_acronym_scalar.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import sys
import os

from graphql.language import ast
from graphql import GraphQLError

import unittest

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(
os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

from unittest import TestCase
from scalars.organization_acronym import (
scalar_error_only_types,
scalar_error_type,
Acronym
)


class TestOrganizationScalar(unittest.TestCase):
class TestOrganizationScalar(TestCase):

def test_valid_acronym_serialize(self):
test_value = 'TEST_ORG'
Expand Down
14 changes: 2 additions & 12 deletions api/tests/test_organization_mutations.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from queries import schema
from backend.security_check import SecurityAnalysisBackend
from models import (
Organizations,
Domains,
Expand All @@ -31,9 +24,6 @@
Spf_scans,
Ssl_scans
)
from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def organization_mutation_db_init():
Expand Down
10 changes: 0 additions & 10 deletions api/tests/test_organization_resolver_access_control.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from models import Organizations, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def org_perm_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
10 changes: 0 additions & 10 deletions api/tests/test_organization_resolver_values.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath

import pytest
from flask import Request
from graphene.test import Client
from flask_bcrypt import Bcrypt

from unittest import TestCase

from werkzeug.test import create_environ

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from app import app
from db import db_session
from models import Organizations, Domains, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend


@pytest.fixture(scope='class')
def org_perm_test_db_init():
bcrypt = Bcrypt(app)
Expand Down
Loading