def test_unregister(self): chid = str(uuid.uuid4()) m = get_rotating_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert (len(results) == 1) eq_(results[0]["chids"], set([chid])) message.unregister_channel(self.uaid, chid) # Verify its not in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert (len(results) == 1) eq_(results[0]["chids"], set([])) # Test for the very unlikely case that there's no 'chid' m.connection.update_item = Mock() m.connection.update_item.return_value = { 'Attributes': { 'uaid': { 'S': self.uaid } }, 'ConsumedCapacityUnits': 0.5 } r = message.unregister_channel(self.uaid, dummy_chid) eq_(r, False)
def test_unregister(self): chid = str(uuid.uuid4()) m = get_rotating_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert len(results) == 1 eq_(results[0]["chids"], set([chid])) message.unregister_channel(self.uaid, chid) # Verify its not in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert len(results) == 1 eq_(results[0]["chids"], set([])) # Test for the very unlikely case that there's no 'chid' m.connection.update_item = Mock() m.connection.update_item.return_value = {"Attributes": {"uaid": {"S": self.uaid}}, "ConsumedCapacityUnits": 0.5} r = message.unregister_channel(self.uaid, "test") eq_(r, False)
def test_unregister(self): chid = str(uuid.uuid4()) m = get_rotating_message_tablename(boto_resource=self.resource) message = Message(m, boto_resource=self.resource) message.register_channel(self.uaid, chid) # Verify its in the db lm = self.resource.Table(m) # Verify it's in the db response = lm.query( KeyConditions={ 'uaid': { 'AttributeValueList': [self.uaid], 'ComparisonOperator': 'EQ' }, 'chidmessageid': { 'AttributeValueList': [" "], 'ComparisonOperator': 'EQ' }, }, ConsistentRead=True, ) results = list(response.get('Items')) assert len(results) == 1 assert results[0]["chids"] == {chid} message.unregister_channel(self.uaid, chid) # Verify its not in the db response = lm.query( KeyConditions={ 'uaid': { 'AttributeValueList': [self.uaid], 'ComparisonOperator': 'EQ' }, 'chidmessageid': { 'AttributeValueList': [" "], 'ComparisonOperator': 'EQ' }, }, ConsistentRead=True, ) results = list(response.get('Items')) assert len(results) == 1 assert results[0].get("chids") is None # Test for the very unlikely case that there's no 'chid' mtable = Mock() mtable.update_item = Mock(return_value={ 'Attributes': { 'uaid': self.uaid }, 'ResponseMetaData': {} }) message.table = mtable r = message.unregister_channel(self.uaid, dummy_chid) assert r is False
def test_all_channels(self): chid = str(uuid.uuid4()) chid2 = str(uuid.uuid4()) m = get_rotating_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) message.register_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert chid in chans assert chid2 in chans message.unregister_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert chid2 not in chans assert chid in chans
def test_all_channels(self): chid = str(uuid.uuid4()) chid2 = str(uuid.uuid4()) m = get_rotating_message_tablename(boto_resource=self.resource) message = Message(m, boto_resource=self.resource) message.register_channel(self.uaid, chid) message.register_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert chid in chans assert chid2 in chans message.unregister_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert chid2 not in chans assert chid in chans
def test_all_channels(self): chid = str(uuid.uuid4()) chid2 = str(uuid.uuid4()) m = get_rotating_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) message.register_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert (chid in chans) assert (chid2 in chans) message.unregister_channel(self.uaid, chid2) _, chans = message.all_channels(self.uaid) assert (chid2 not in chans) assert (chid in chans)
def test_unregister(self): chid = str(uuid.uuid4()) m = get_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert(len(results) == 1) eq_(results[0]["chids"], set([chid])) message.unregister_channel(self.uaid, chid) # Verify its not in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert(len(results) == 1) eq_(results[0]["chids"], set([]))
def test_unregister(self): chid = str(uuid.uuid4()) m = get_message_table() message = Message(m, SinkMetrics()) message.register_channel(self.uaid, chid) # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert (len(results) == 1) eq_(results[0]["chids"], set([chid])) message.unregister_channel(self.uaid, chid) # Verify its not in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) assert (len(results) == 1) eq_(results[0]["chids"], set([]))