예제 #1
0
파일: stats.py 프로젝트: EliotBerriot/1flow
def synchronize_statsd_tags_gauges(full=False):

    with benchmark('synchronize statsd gauges for Tag.*'):

        statsd.gauge('tags.counts.total', Tag._get_collection().count())

        if full:
            duplicates = Tag.objects(duplicate_of__ne=None).no_cache()
            statsd.gauge('tags.counts.duplicates', duplicates.count())
예제 #2
0
class TagsTest(TestCase):

    def setUp(self):

        self.t1 = Tag(name='test1').save()
        self.t2 = Tag(name='test2').save()
        self.t3 = Tag(name='test3').save()

    def tearDown(self):
        Tag.drop_collection()

    def test_add_parent(self):

        self.t2.add_parent(self.t1)
        self.t3.add_parent(self.t1)

        self.assertEquals(self.t1 in self.t2.parents, True)
        self.assertEquals(self.t1 in self.t3.parents, True)

        self.assertEquals(self.t2 in self.t1.children, True)
        self.assertEquals(self.t3 in self.t1.children, True)

    def test_add_child(self):

        self.t1.add_child(self.t2)
        self.t1.add_child(self.t3)

        self.assertEquals(self.t1 in self.t2.parents, True)
        self.assertEquals(self.t1 in self.t3.parents, True)

        self.assertEquals(self.t2 in self.t1.children, True)
        self.assertEquals(self.t3 in self.t1.children, True)
예제 #3
0
class TagsTest(TestCase):
    def setUp(self):

        self.t1 = Tag(name='test1').save()
        self.t2 = Tag(name='test2').save()
        self.t3 = Tag(name='test3').save()

    def tearDown(self):
        Tag.drop_collection()

    def test_add_parent(self):

        self.t2.add_parent(self.t1)
        self.t3.add_parent(self.t1)

        self.assertEquals(self.t1 in self.t2.parents, True)
        self.assertEquals(self.t1 in self.t3.parents, True)

        self.assertEquals(self.t2 in self.t1.children, True)
        self.assertEquals(self.t3 in self.t1.children, True)

    def test_add_child(self):

        self.t1.add_child(self.t2)
        self.t1.add_child(self.t3)

        self.assertEquals(self.t1 in self.t2.parents, True)
        self.assertEquals(self.t1 in self.t3.parents, True)

        self.assertEquals(self.t2 in self.t1.children, True)
        self.assertEquals(self.t3 in self.t1.children, True)
예제 #4
0
 def tearDown(self):
     Tag.drop_collection()
예제 #5
0
    def setUp(self):

        self.t1 = Tag(name='test1').save()
        self.t2 = Tag(name='test2').save()
        self.t3 = Tag(name='test3').save()
예제 #6
0
LOGGER     = logging.getLogger(__file__)

# Use the test database not to pollute the production/development one.
RedisStatsCounter.REDIS = TEST_REDIS

TEST_REDIS.flushdb()

connect_mongodb_testsuite()

# Empty the database before starting in case an old test failed to tearDown().
Article.drop_collection()
Read.drop_collection()
User.drop_collection()
Group.drop_collection()
Feed.drop_collection()
Tag.drop_collection()
Folder.drop_collection()
WebSite.drop_collection()
Author.drop_collection()


class ThrottleIntervalTest(TestCase):

    def test_lower_interval_with_etag_or_modified(self):

        t = Feed.throttle_fetch_interval

        some_news = 10
        no_dupe   = 0
        no_mutual = 0
예제 #7
0
 def tearDown(self):
     Tag.drop_collection()
예제 #8
0
    def setUp(self):

        self.t1 = Tag(name='test1').save()
        self.t2 = Tag(name='test2').save()
        self.t3 = Tag(name='test3').save()
예제 #9
0
LOGGER = logging.getLogger(__file__)

# Use the test database not to pollute the production/development one.
RedisStatsCounter.REDIS = TEST_REDIS

TEST_REDIS.flushdb()

connect_mongodb_testsuite()

# Empty the database before starting in case an old test failed to tearDown().
Article.drop_collection()
Read.drop_collection()
User.drop_collection()
Group.drop_collection()
Feed.drop_collection()
Tag.drop_collection()
Folder.drop_collection()
WebSite.drop_collection()
Author.drop_collection()


class ThrottleIntervalTest(TestCase):
    def test_lower_interval_with_etag_or_modified(self):

        t = Feed.throttle_fetch_interval

        some_news = 10
        no_dupe = 0
        no_mutual = 0

        self.assertEquals(