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
85 changes: 0 additions & 85 deletions api/functions/generate_enums.py

This file was deleted.

4 changes: 0 additions & 4 deletions api/model_enums/organiztions.py

This file was deleted.

2 changes: 1 addition & 1 deletion api/scalars/organization_acronym.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def parse_value(value):
raise GraphQLError(scalar_error_type('String', value))

if not ACRONYM_REGEX.search(value):
raise GraphQLError(scalar_error_type("String", value))
raise GraphQLError(scalar_error_type("Acronym", value))
return value

@staticmethod
Expand Down
2 changes: 0 additions & 2 deletions api/schemas/organizations_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from functions.auth_functions import is_super_admin
from functions.input_validators import cleanse_input

from model_enums.organiztions import OrganizationsEnum

from models import (
Organizations,
User_affiliations,
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_auth_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from app import app
from db import db
from models import Users, User_affiliations, Organizations
Expand All @@ -21,7 +19,6 @@
is_user_write,
is_user_read
)
remove_seed()


@pytest.fixture(scope='class')
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_auth_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from app import app
from db import db
from queries import schema
from models import Users, User_affiliations, Organizations
from backend.security_check import SecurityAnalysisBackend
remove_seed()


@pytest.fixture(scope='class')
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_cost_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from db import db
from app import app
from queries import schema
from models import Users
from backend.security_check import SecurityAnalysisBackend
remove_seed()


@pytest.fixture(scope='class')
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_depth_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from app import app
from db import db
from queries import schema
from models import Users
from backend.security_check import SecurityAnalysisBackend
remove_seed()


@pytest.fixture(scope='class')
Expand Down
12 changes: 4 additions & 8 deletions api/tests/test_domains_resolver_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@

from werkzeug.test import create_environ

from manage import seed, remove_seed
# 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)))

seed()
from app import app
from db import db
from models import Organizations, Domains, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend
remove_seed()

# 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)))


@pytest.fixture(scope='class')
Expand Down
13 changes: 5 additions & 8 deletions api/tests/test_notification_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

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 manage import seed, remove_seed
from app import app

seed()
from queries import schema
from backend.security_check import SecurityAnalysisBackend
remove_seed()

# 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)))


class TestPasswordReset:
Expand Down
63 changes: 63 additions & 0 deletions api/tests/test_organization_acronym_scalar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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 scalars.organization_acronym import (
scalar_error_only_types,
scalar_error_type,
Acronym
)


class TestOrganizationScalar(unittest.TestCase):

def test_valid_acronym_serialize(self):
test_value = 'TEST_ORG'
assert Acronym.serialize(test_value)

def test_invalid_acronym_serialize(self):
test_value = 'fdsaf'
with self.assertRaisesRegex(GraphQLError, scalar_error_type("Acronym", test_value)):
Acronym.serialize(test_value)

def test_invalid_value_acronym_serialize(self):
test_value = 3213
with self.assertRaisesRegex(GraphQLError, scalar_error_type("String", test_value)):
Acronym.serialize(test_value)

def test_valid_acronym_parse_value(self):
test_value = 'TEST_ORG'
assert Acronym.parse_value(test_value)

def test_invalid_acronym_parse_value(self):
test_value = 'fdasf'
with self.assertRaisesRegex(GraphQLError, scalar_error_type("Acronym", test_value)):
Acronym.parse_value(test_value)

def test_invalid_value_acronym_parse_value(self):
test_value = 654645
with self.assertRaisesRegex(GraphQLError, scalar_error_type("String", test_value)):
Acronym.serialize(test_value)

def test_valid_acronym_parse_literal(self):
test_value = ast.StringValue(
value='TEST_ORG'
)
assert Acronym.parse_literal(test_value)

def test_wrong_ast_type_url_parse_literal(self):
test_value = ast.IntValue(
value="1234"
)
with self.assertRaisesRegex(GraphQLError, scalar_error_only_types("strings", "acronym", str(ast.Type))):
Acronym.parse_literal(test_value)
14 changes: 5 additions & 9 deletions api/tests/test_organization_resolver_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@

from werkzeug.test import create_environ

from manage import seed, remove_seed
# 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)))

seed()
from app import app
from db import db
from models import Organizations, Domains, Users, User_affiliations
from models import Organizations, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend
remove_seed()

# 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)))


@pytest.fixture(scope='class')
Expand Down
12 changes: 4 additions & 8 deletions api/tests/test_organization_resolver_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@

from werkzeug.test import create_environ

from manage import seed, remove_seed
# 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)))

seed()
from app import app
from db import db
from models import Organizations, Domains, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend
remove_seed()

# 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)))


@pytest.fixture(scope='class')
Expand Down
2 changes: 1 addition & 1 deletion api/tests/test_url_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import unittest

# This is the only way I could get imports to work for unit testing. TODO: See if there is a better way!
# 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__))))
Expand Down
14 changes: 5 additions & 9 deletions api/tests/test_user_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@

from werkzeug.test import create_environ

from manage import seed, remove_seed
# 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)))

seed()
from app import app
from db import db
from models import Organizations, Domains, Users, User_affiliations
from models import Organizations, Users, User_affiliations
from queries import schema
from backend.security_check import SecurityAnalysisBackend
remove_seed()

# 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)))


@pytest.fixture(scope='class')
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_user_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from app import app
from db import db
from queries import schema
from models import Users
from backend.security_check import SecurityAnalysisBackend
from functions.error_messages import *
remove_seed()


@pytest.fixture(scope='class')
Expand Down
Loading