Skip to content

Added api.py methods testcases#1864

Merged
PeterSurda merged 7 commits intoBitmessage:v0.6from
kdcis:v0.6-test-api-testcase
Dec 3, 2021
Merged

Added api.py methods testcases#1864
PeterSurda merged 7 commits intoBitmessage:v0.6from
kdcis:v0.6-test-api-testcase

Conversation

@kdcis
Copy link
Copy Markdown
Contributor

@kdcis kdcis commented Oct 15, 2021

Added statusBar, getAllInboxMessages, getAllInboxMessageIds, getInboxMessageById, getInboxMessagesByReceiver, trashMessage, trashInboxMessage & addSubscription, methods testcases

Comment thread src/bitmessagemain.py Outdated
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py
Comment thread src/tests/test_process.py Outdated
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from 443ad5a to a172230 Compare October 22, 2021 08:30
Comment thread src/bitmessagemain.py Outdated
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from 734207d to 79812fd Compare October 26, 2021 12:37
Comment thread src/tests/test_api.py Outdated
Copy link
Copy Markdown
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make test strings into variables (maybe class variables)

@kdcis kdcis changed the title Added statusBar, getAllInboxMessages & addSubscription methods testcases Added statusBar, getAllInboxMessages, getAllInboxMessageIds, getInboxMessageById, getInboxMessagesByReceiver, trashMessage, trashInboxMessage & addSubscription, methods testcases Oct 28, 2021
@kdcis kdcis changed the title Added statusBar, getAllInboxMessages, getAllInboxMessageIds, getInboxMessageById, getInboxMessagesByReceiver, trashMessage, trashInboxMessage & addSubscription, methods testcases Added api.py methods testcases Oct 28, 2021
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from 18c48a9 to d84cd8a Compare October 28, 2021 14:03
Comment thread src/api.py Outdated
Comment thread src/bitmessagemain.py
Comment thread src/tests/test_api.py Outdated
Copy link
Copy Markdown
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the changes as discussed

@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from d84cd8a to 754d20b Compare October 29, 2021 07:01
Comment thread src/testmode_init.py Outdated
Copy link
Copy Markdown
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix linter issues

Comment thread src/tests/test_api.py
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py Outdated
Comment thread src/testmode_init.py
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from dfe8c1e to 4553802 Compare November 2, 2021 07:39
Comment thread src/tests/test_api.py
Comment thread src/tests/test_api.py
Comment thread src/api.py Outdated
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from 867d419 to 8bf2c78 Compare November 11, 2021 08:39
Comment thread src/api.py Outdated
Copy link
Copy Markdown
Collaborator

@g1itch g1itch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another portion of garbage );

Comment thread src/testmode_init.py
Comment thread src/tests/samples.py Outdated
sample_deterministic_addr4 = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'

sample_statusbar_msg = "new status bar message"
sample_inbox_msg_receiver_address = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why double the sample_deterministic_addr4 3 lines above?

Comment thread src/tests/samples.py
Comment thread src/tests/test_api.py Outdated
Comment thread src/tests/test_api.py Outdated
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch 3 times, most recently from 8d67694 to 53cd1d2 Compare November 15, 2021 16:21
Comment thread src/tests/test_process.py
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from 53cd1d2 to 682f042 Compare November 16, 2021 07:24
Comment thread src/api.py Outdated
"""Test two numeric params"""
return a + b

@command('clearUISignalQueue')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something to make this only available in test mode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preferred way would be to create an additional decorator for testmode functions.

Comment thread src/api.py Outdated
"""Update GUI statusbar message"""
queues.UISignalQueue.put(('updateStatusBar', message))

@command('getStatusBar')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also only in test mode

Comment thread src/api.py Outdated
self.aliases = aliases

def __call__(self, func):
if func.__name__ in ["HandleclearUISignalQueue", "HandleGetStatusBar"] \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a constant, say

TESTMODE_FUNCTIONS = ["HandleclearUISignalQueue", "HandleGetStatusBar"]

if func.__name__ in TESTMODE_FUNCTIONS and not state.testmode:
    return None

Comment thread src/tests/samples.py
Copy link
Copy Markdown
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor change.

Comment thread src/tests/test_api.py Outdated
len(json.loads(
self.api.getAllInboxMessageIds())["inboxMessageIds"]) == 2
)
self.assertTrue(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertEqual

Comment thread src/tests/test_api.py Outdated
len(json.loads(
self.api.getInboxMessageById(hexlify(sample_inbox_msg_ids[2])))["inboxMessage"]) == 1
)
self.assertTrue(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertEqual

Comment thread src/tests/test_api.py
kdcis added 7 commits December 2, 2021 19:11
…MessageById, getInboxMessagesByReceiver, trashMessage, trashInboxMessage & addSubscription, methods testcases & updated related functions
…r functions, replaced sample_inbox_msg_receiver_address by sample_deterministic_addr4
…& added print for getAllInboxMessages to check build failure
… api.py and separated inbox & trash testcases
@kdcis kdcis force-pushed the v0.6-test-api-testcase branch from b3b5dae to 5771f21 Compare December 2, 2021 13:41
Comment thread src/api.py
self.aliases = aliases

def __call__(self, func):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why space?

Comment thread src/tests/test_api.py
len(json.loads(
self.api.getAllInboxMessages())["inboxMessages"]),
4,
json.loads(self.api.getAllInboxMessages())["inboxMessages"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment explaining this is the custom error message to aid in debugging.

@PeterSurda PeterSurda merged commit 5771f21 into Bitmessage:v0.6 Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants