Skip to content

Commit

Permalink
Short drop down list
Browse files Browse the repository at this point in the history
  • Loading branch information
john681611 committed Sep 7, 2023
1 parent 030c044 commit 121ce35
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 121 deletions.
12 changes: 8 additions & 4 deletions application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const GapAnalysis = () => {
const result = await axios.get(`${apiUrl}/standards`);
setLoading(false);
setStandardOptions(
standardOptionsDefault.concat(result.data.map((x) => ({ key: x, text: x, value: x })))
standardOptionsDefault.concat(result.data.sort().map((x) => ({ key: x, text: x, value: x })))
);
};

Expand Down Expand Up @@ -159,7 +159,8 @@ export const GapAnalysis = () => {
target="_blank"
>
<Icon name="external" />
</a>
</a>{' '}
{gapAnalysis[key].start.id}
<br />
{gapAnalysis[key].start.sectionID}
{gapAnalysis[key].start.description}
Expand Down Expand Up @@ -234,8 +235,11 @@ export const GapAnalysis = () => {
trigger={
<span>
{path.end.name} {path.end.sectionID} {path.end.section}{' '}
{path.end.subsection} {path.end.description} {GetStrength(path.score)}:
{path.score}){' '}
{path.end.subsection} {path.end.description}(
<b style={{ color: GetStrengthColor(path.score) }}>
{GetStrength(path.score)}:{path.score}
</b>
){' '}
<a
href={`/node/standard/${path.end.name}/section/${path.end.section}`}
target="_blank"
Expand Down
245 changes: 128 additions & 117 deletions application/tests/db_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,157 +1142,168 @@ def test_gap_analysis_disconnected(self):
collection.neo_db.connected = False
self.assertEqual(collection.gap_analysis(["a", "b"]), None)

@patch.object(db.NEO_DB, 'gap_analysis')
@patch.object(db.NEO_DB, "gap_analysis")
def test_gap_analysis_no_nodes(self, gap_mock):
collection = db.Node_collection()
collection.neo_db.connected = True

gap_mock.return_value = ([], [])
self.assertEqual(collection.gap_analysis(["a", "b"]), {})

@patch.object(db.NEO_DB, 'gap_analysis')
@patch.object(db.NEO_DB, "gap_analysis")
def test_gap_analysis_no_links(self, gap_mock):
collection = db.Node_collection()
collection.neo_db.connected = True

gap_mock.return_value = ([{'id': 1}], [])
self.assertEqual(collection.gap_analysis(["a", "b"]), {1: {'start': {'id': 1}, 'paths': {}}} )

@patch.object(db.NEO_DB, 'gap_analysis')
gap_mock.return_value = ([{"id": 1}], [])
self.assertEqual(
collection.gap_analysis(["a", "b"]), {1: {"start": {"id": 1}, "paths": {}}}
)

@patch.object(db.NEO_DB, "gap_analysis")
def test_gap_analysis_one_link(self, gap_mock):
collection = db.Node_collection()
collection.neo_db.connected = True
path = [
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 1,
},
{
"end": {
"id": 2,
},
"relationship": "LINKED_TO",
"start": {
"id": "a"
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
]
gap_mock.return_value = ([{'id': 1}], [{'start':{'id': 1}, 'end': {'id': 2}, 'path': path}])
expected = {1: {'start': {'id': 1}, 'paths': {
2: {'end': {'id': 2},
'path': path,
'score': 0}}
}}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)

@patch.object(db.NEO_DB, 'gap_analysis')
},
{
"end": {
"id": 2,
},
"relationship": "LINKED_TO",
"start": {"id": "a"},
},
]
gap_mock.return_value = (
[{"id": 1}],
[{"start": {"id": 1}, "end": {"id": 2}, "path": path}],
)
expected = {
1: {
"start": {"id": 1},
"paths": {2: {"end": {"id": 2}, "path": path, "score": 0}},
}
}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)

@patch.object(db.NEO_DB, "gap_analysis")
def test_gap_analysis_duplicate_link_path_existing_lower(self, gap_mock):
collection = db.Node_collection()
collection.neo_db.connected = True
path = [
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 1,
},
{
"end": {
"id": 2,
},
"relationship": "LINKED_TO",
"start": {
"id": "a"
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
]
},
{
"end": {
"id": 2,
},
"relationship": "LINKED_TO",
"start": {"id": "a"},
},
]
path2 = [
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 2,
},
"relationship": "RELATED",
"start": {
"id": "a"
},
},
{
"end": {
"id": 2,
},
]
gap_mock.return_value = ([{'id': 1}], [{'start':{'id': 1}, 'end': {'id': 2}, 'path': path}, {'start':{'id': 1}, 'end': {'id': 2}, 'path': path2}])
expected = {1: {'start': {'id': 1}, 'paths': {
2: {'end': {'id': 2},
'path': path,
'score': 0}}
}}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)

@patch.object(db.NEO_DB, 'gap_analysis')
"relationship": "RELATED",
"start": {"id": "a"},
},
]
gap_mock.return_value = (
[{"id": 1}],
[
{"start": {"id": 1}, "end": {"id": 2}, "path": path},
{"start": {"id": 1}, "end": {"id": 2}, "path": path2},
],
)
expected = {
1: {
"start": {"id": 1},
"paths": {2: {"end": {"id": 2}, "path": path, "score": 0}},
}
}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)

@patch.object(db.NEO_DB, "gap_analysis")
def test_gap_analysis_duplicate_link_path_existing_higher(self, gap_mock):
collection = db.Node_collection()
collection.neo_db.connected = True
path = [
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 2,
},
"relationship": "LINKED_TO",
"start": {
"id": "a"
},
},
{
"end": {
"id": 2,
},
]
"relationship": "LINKED_TO",
"start": {"id": "a"},
},
]
path2 = [
{
"end": {
"id": 1,
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
{
"end": {
"id": 1,
},
{
"end": {
"id": 2,
},
"relationship": "RELATED",
"start": {
"id": "a"
},
"relationship": "LINKED_TO",
"start": {
"id": "a",
},
]
gap_mock.return_value = ([{'id': 1}], [{'start':{'id': 1}, 'end': {'id': 2}, 'path': path2}, {'start':{'id': 1}, 'end': {'id': 2}, 'path': path}])
expected = {1: {'start': {'id': 1}, 'paths': {
2: {'end': {'id': 2},
'path': path,
'score': 0}}
}}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)
},
{
"end": {
"id": 2,
},
"relationship": "RELATED",
"start": {"id": "a"},
},
]
gap_mock.return_value = (
[{"id": 1}],
[
{"start": {"id": 1}, "end": {"id": 2}, "path": path2},
{"start": {"id": 1}, "end": {"id": 2}, "path": path},
],
)
expected = {
1: {
"start": {"id": 1},
"paths": {2: {"end": {"id": 2}, "path": path, "score": 0}},
}
}
self.assertEqual(collection.gap_analysis(["a", "b"]), expected)


if __name__ == "__main__":
unittest.main()

0 comments on commit 121ce35

Please sign in to comment.