-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from RnDAO/dev_amin_lib_update
Updated DB collection!
- Loading branch information
Showing
13 changed files
with
187 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
setup( | ||
name="tc-messageBroker", | ||
version="1.1.0", | ||
version="1.1.1", | ||
author="Mohammad Amin Dadgar, RnDAO", | ||
maintainer="Mohammad Amin Dadgar", | ||
maintainer_email="[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
from .choreography_base import IChoreography | ||
from .transactions import DISCORD_UPDATE_CHANNELS_TRANSACTIONS | ||
from .transactions import ( | ||
DISCORD_UPDATE_CHANNELS_TRANSACTIONS, | ||
DISCORD_SCHEDULED_JOB_TRANSACTIONS, | ||
) | ||
|
||
|
||
DISCORD_UPDATE_CHANNELS = IChoreography( | ||
name="DISCORD_UPDATE_CHANNELS", | ||
transactions=DISCORD_UPDATE_CHANNELS_TRANSACTIONS, | ||
) | ||
|
||
DISCORD_SCHEDULED_JOB = IChoreography( | ||
name="DISCORD_UPDATE_CHANNELS", | ||
transactions=DISCORD_SCHEDULED_JOB_TRANSACTIONS, | ||
) | ||
|
||
|
||
class ChoreographyDict: | ||
DISCORD_UPDATE_CHANNELS = DISCORD_UPDATE_CHANNELS | ||
DISCORD_SCHEDULED_JOB = DISCORD_SCHEDULED_JOB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,39 @@ | ||
from tc_messageBroker.rabbit_mq.saga.choreography_base import IChoreography | ||
from tc_messageBroker.rabbit_mq.saga.transactions import ( | ||
DISCORD_UPDATE_CHANNELS_TRANSACTIONS, | ||
DISCORD_SCHEDULED_JOB_TRANSACTIONS, | ||
) | ||
|
||
|
||
def test_choreography(): | ||
def test_choreography_discord_update_channels_no_inputs(): | ||
choreography = IChoreography(name=None, transactions=None) | ||
|
||
assert choreography.name is None | ||
assert choreography.transactions is None | ||
|
||
|
||
def test_choreography_discord_update_channels(): | ||
choreography = IChoreography( | ||
name="sample", transactions=DISCORD_UPDATE_CHANNELS_TRANSACTIONS | ||
) | ||
|
||
assert choreography.name == "sample" | ||
assert choreography.transactions == DISCORD_UPDATE_CHANNELS_TRANSACTIONS | ||
|
||
|
||
def test_choreography_discord_update_channels_wrong_input(): | ||
choreography = IChoreography( | ||
name="sample", transactions=DISCORD_UPDATE_CHANNELS_TRANSACTIONS | ||
) | ||
|
||
assert choreography.name != "some_choreography" | ||
assert choreography.transactions != DISCORD_SCHEDULED_JOB_TRANSACTIONS | ||
|
||
|
||
def test_choreography_discord_job_transactions(): | ||
choreography = IChoreography( | ||
name="sample", transactions=DISCORD_SCHEDULED_JOB_TRANSACTIONS | ||
) | ||
|
||
assert choreography.name == "sample" | ||
assert choreography.transactions == DISCORD_SCHEDULED_JOB_TRANSACTIONS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from tc_messageBroker.rabbit_mq.saga.transactions import ( | ||
DISCORD_SCHEDULED_JOB_TRANSACTIONS, | ||
DISCORD_UPDATE_CHANNELS_TRANSACTIONS, | ||
) | ||
from tc_messageBroker.rabbit_mq.queue import Queue | ||
from tc_messageBroker.rabbit_mq.event import Event | ||
from tc_messageBroker.rabbit_mq.status import Status | ||
|
||
|
||
def test_discord_update_channels_tx(): | ||
tx = DISCORD_UPDATE_CHANNELS_TRANSACTIONS | ||
|
||
assert len(tx) == 2 | ||
assert tx[0].order == 1 | ||
assert tx[0].queue == Queue.DISCORD_BOT | ||
assert tx[0].event == Event.DISCORD_BOT.FETCH | ||
assert tx[0].status == Status.NOT_STARTED | ||
|
||
assert tx[1].order == 2 | ||
assert tx[1].queue == Queue.DISCORD_ANALYZER | ||
assert tx[1].event == Event.DISCORD_ANALYZER.RUN | ||
assert tx[1].status == Status.NOT_STARTED | ||
|
||
|
||
def test_discord_scheduled_job_tx(): | ||
tx = DISCORD_SCHEDULED_JOB_TRANSACTIONS | ||
|
||
assert len(tx) == 1 | ||
# assert tx[0].order == 1 | ||
# assert tx[0].queue == Queue.DISCORD_BOT | ||
# assert tx[0].event == Event.DISCORD_BOT.FETCH | ||
# assert tx[0].status == Status.NOT_STARTED | ||
|
||
assert tx[0].order == 2 | ||
assert tx[0].queue == Queue.DISCORD_ANALYZER | ||
assert tx[0].event == Event.DISCORD_ANALYZER.RUN_ONCE | ||
assert tx[0].status == Status.NOT_STARTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from tc_messageBroker.rabbit_mq.saga.saga_base import Saga | ||
from tc_messageBroker.rabbit_mq.saga.transaction_base import ITransaction | ||
from tc_messageBroker.rabbit_mq.saga.choreography_base import IChoreography | ||
from datetime import datetime | ||
from tc_messageBroker.rabbit_mq.status import Status | ||
|
||
|
||
def test_start_tx(): | ||
choreography = IChoreography( | ||
name="choreography_with_random_tx", | ||
transactions=[ | ||
ITransaction("queue", "event", 5, Status.NOT_STARTED), | ||
ITransaction("queue1", "event1", 2, Status.NOT_STARTED), | ||
ITransaction("queue", "event", 3, Status.SUCCESS), | ||
ITransaction("queue", "event", 1, Status.FAILED), | ||
ITransaction("queue", "event", 0, Status.CANCELLED), | ||
], | ||
) | ||
|
||
saga = Saga(choreography, Status.NOT_STARTED, data=None, created_at=datetime.now()) | ||
|
||
def sample_publish(**kwargs): | ||
assert kwargs["queue_name"] == choreography.transactions[1].queue | ||
assert kwargs["event"] == choreography.transactions[1].event | ||
assert kwargs["content"]["uuid"] == saga.uuid | ||
|
||
saga.start( | ||
publish_method=sample_publish, | ||
mongo_connection="", | ||
test_mode=True, | ||
) | ||
|
||
assert saga.status == Status.IN_PROGRESS | ||
assert saga.choreography.transactions[0].status == Status.NOT_STARTED | ||
assert saga.choreography.transactions[1].status == Status.NOT_STARTED | ||
assert saga.choreography.transactions[2].status == Status.SUCCESS | ||
assert saga.choreography.transactions[3].status == Status.FAILED | ||
assert saga.choreography.transactions[4].status == Status.CANCELLED |