Beispiel #1
0
 def test_send_payload_insert_post_into_posts_table(self, mock_handle_receive, mock_send_payload,
                                                    mock_pod_preferences):
     process(Mock())
     post = Post.get(Post.guid=="foobar")
     assert post
     assert post.nodes.count() == 1
     assert post.nodes.first().host == "sub.example.com"
Beispiel #2
0
 def test_send_payload_success_clears_existing_node_failure_count(
     self, mock_handle_receive, mock_send_document, mock_pod_preferences
 ):
     Node.create(host="sub.example.com", last_success=datetime.datetime.now(), failure_count=1)
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.failure_count == 0
Beispiel #3
0
 def test_send_payload_stores_unknown_node_into_db(self, mock_handle_receive, mock_send_payload,
                                                   mock_pod_preferences):
     process(Mock())
     assert Node.select().count() == 1
     node = Node.get(Node.host=="sub.example.com")
     assert node
     assert node.https
Beispiel #4
0
 def test_send_payload_failure_updates_existing_node_failure_count(
     self, mock_handle_receive, mock_send_payload, mock_pod_preferences
 ):
     Node.create(host="sub.example.com", last_success=datetime.datetime.now())
     mock_send_payload.return_value = {"result": False, "https": False}
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.failure_count == 1
Beispiel #5
0
 def test_send_payload_updates_existing_node_in_db(
     self, mock_handle_receive, mock_send_document, mock_pod_preferences
 ):
     Node.create(host="sub.example.com", last_success=datetime.datetime.now())
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.total_delivered == 1
     assert node.https
 def test_send_payload_insert_post_into_posts_table(self,
                                                    mock_handle_receive,
                                                    mock_send_document,
                                                    mock_pod_preferences):
     process(Mock())
     post = Post.get(Post.guid == "foobar")
     assert post
     assert post.nodes.count() == 1
     assert post.nodes.first().host == "sub.example.com"
 def test_send_payload_success_clears_existing_node_failure_count(
         self, mock_handle_receive, mock_send_document,
         mock_pod_preferences):
     Node.create(host="sub.example.com",
                 last_success=datetime.datetime.now(),
                 failure_count=1)
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.failure_count == 0
 def test_send_payload_failure_updates_existing_node_failure_count(
         self, mock_handle_receive, mock_send_payload,
         mock_pod_preferences):
     Node.create(host="sub.example.com",
                 last_success=datetime.datetime.now())
     mock_send_payload.return_value = {"result": False, "https": False}
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.failure_count == 1
 def test_send_payload_stores_unknown_node_into_db(self,
                                                   mock_handle_receive,
                                                   mock_send_document,
                                                   mock_pod_preferences):
     process(Mock())
     assert Node.select().count() == 1
     node = Node.get(Node.host == "sub.example.com")
     assert node
     assert node.https
Beispiel #10
0
 def test_send_payload_called(self, mock_send_document, mock_handle_receive,
                              mock_pod_preferences):
     process("payload")
     assert mock_send_document.call_count == 1
     mock_send_document.assert_called_once_with(
         url="https://sub.example.com/receive/public",
         data="payload",
         headers=HEADERS,
     )
Beispiel #11
0
 def test_send_payload_updates_existing_node_in_db(self,
                                                   mock_handle_receive,
                                                   mock_send_document,
                                                   mock_pod_preferences):
     Node.create(host="sub.example.com",
                 last_success=datetime.datetime.now())
     process(Mock())
     node = Node.get(Node.host == "sub.example.com")
     assert node.total_delivered == 1
     assert node.https
Beispiel #12
0
 def test_send_payload_called(self, mock_handle_receive, mock_send_document, mock_pod_preferences):
     process(Mock())
     assert mock_send_document.call_count == 1
Beispiel #13
0
 def test_log_statistics_called(self, mock_statistics, mock_handle_receive, mock_pod_preferences):
     process(Mock())
     assert mock_statistics.call_count == 1
Beispiel #14
0
 def test_send_payload_called(self, mock_handle_receive, mock_send_document,
                              mock_pod_preferences):
     process(Mock())
     assert mock_send_document.call_count == 1
Beispiel #15
0
 def test_log_statistics_called(self, mock_statistics, mock_handle_receive,
                                mock_pod_preferences):
     process(Mock())
     assert mock_statistics.call_count == 1