<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest
import time
from frappe.frappeclient import FrappeClient
from frappe.events_streaming.doctype.event_producer.event_producer import pull_from_node, get_current_node

def create_event_producer(producer_url):
	event_producer = frappe.new_doc('Event Producer')
	event_producer.producer_url = producer_url
	event_producer.append('event_configuration', {
		'ref_doctype': 'ToDo',
		'use_same_name': 1
	})
	event_producer.append('event_configuration', {
		'ref_doctype': 'Note',
		'use_same_name': 1
	})
	event_producer.user = 'Administrator'
	event_producer.insert()

class TestEventProducer(unittest.TestCase):
	def setUp(self):
		self.producer_url = 'http://test_site_producer:8010'
		if not frappe.db.exists('Event Producer', self.producer_url):
			create_event_producer(self.producer_url)
		frappe.db.sql('delete from tabToDo')
		frappe.db.sql('delete from tabNote')

	def test_insert(self):
		producer = self.get_remote_site()
		producer_doc = insert_into_producer(producer, 'test creation 1 sync')
		self.pull_producer_data()
		self.assertTrue(frappe.db.exists('ToDo', producer_doc.name))

	def test_update(self):
		producer = self.get_remote_site()
		producer_doc = insert_into_producer(producer, 'test update 1')
		producer_doc['description'] = 'test update 2'
		producer_doc = producer.update(producer_doc)
		self.pull_producer_data()
		local_doc = frappe.get_doc(producer_doc.doctype, producer_doc.name)<commit_msg>fix: change port for test site<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest
import time
from frappe.frappeclient import FrappeClient
from frappe.events_streaming.doctype.event_producer.event_producer import pull_from_node, get_current_node

def create_event_producer(producer_url):
	event_producer = frappe.new_doc('Event Producer')
	event_producer.producer_url = producer_url
	event_producer.append('event_configuration', {
		'ref_doctype': 'ToDo',
		'use_same_name': 1
	})
	event_producer.append('event_configuration', {
		'ref_doctype': 'Note',
		'use_same_name': 1
	})
	event_producer.user = 'Administrator'
	event_producer.insert()

class TestEventProducer(unittest.TestCase):
	def setUp(self):
		self.producer_url = 'http://test_site_producer:8000'
		if not frappe.db.exists('Event Producer', self.producer_url):
			create_event_producer(self.producer_url)
		frappe.db.sql('delete from tabToDo')
		frappe.db.sql('delete from tabNote')

	def test_insert(self):
		producer = self.get_remote_site()
		producer_doc = insert_into_producer(producer, 'test creation 1 sync')
		self.pull_producer_data()
		self.assertTrue(frappe.db.exists('ToDo', producer_doc.name))

	def test_update(self):
		producer = self.get_remote_site()
		producer_doc = insert_into_producer(producer, 'test update 1')
		producer_doc['description'] = 'test update 2'
		producer_doc = producer.update(producer_doc)
		self.pull_producer_data()
		local_doc = frappe.get_doc(producer_doc.doctype, producer_doc.name)
{'fraction_non_alphanumeric': 0.1093217714462682, 'fraction_numerical': 0.008671415298854134, 'mean_word_length': 6.408256880733945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679680', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1134, 'n_words': 206}