コード例 #1
0
ファイル: test_utils.py プロジェクト: scooley/osf.io
    def setUp(self):
        super(TestRenderToCSVResponse, self).setUp()
        self.app = TestApp(test_app)
        Node.remove()
        time_now = get_previous_midnight()
        NodeFactory(category='project', date_created=time_now)
        NodeFactory(category='project',
                    date_created=time_now - timedelta(days=1))
        last_time = time_now - timedelta(days=2)
        NodeFactory(category='project', date_created=last_time)
        NodeFactory(category='project', date_created=last_time)
        initial_time = last_time + timedelta(seconds=1)
        get_days_statistics(initial_time)
        midtime = last_time + timedelta(days=1, seconds=1)
        self.time = time_now + timedelta(seconds=1)

        self.initial_static = [
            'id,users,delta_users,unregistered_users,projects,delta_projects,public_projects,'
            'delta_public_projects,registered_projects,delta_registered_projects,date\r',
            construct_query(1, initial_time), '']
        self.latest_static = [
            'id,users,delta_users,unregistered_users,projects,delta_projects,public_projects,'
            'delta_public_projects,registered_projects,delta_registered_projects,date\r',
            construct_query(3, self.time),
            construct_query(2, midtime),
            construct_query(1, initial_time), '']
コード例 #2
0
 def test_delta(self):
     get_days_statistics(datetime.utcnow())
     ProjectFactory()
     ProjectFactory()
     latest = OSFWebsiteStatistics.objects.latest('date')
     get_days_statistics(datetime.utcnow(), latest)
     even_later = OSFWebsiteStatistics.objects.latest('date')
     nt.assert_equal(even_later.delta_projects, 2)
コード例 #3
0
ファイル: test_utils.py プロジェクト: kch8qx/osf.io
 def test_delta(self):
     get_days_statistics(datetime.utcnow())
     NodeFactory(category='project')  # makes 2 nodes
     NodeFactory(category='project')  # makes 2 more nodes
     latest = OSFWebsiteStatistics.objects.latest('date')
     get_days_statistics(datetime.utcnow(), latest)
     even_later = OSFWebsiteStatistics.objects.latest('date')
     nt.assert_equal(even_later.delta_projects, 4)
コード例 #4
0
ファイル: test_utils.py プロジェクト: kch8qx/osf.io
 def test_delta(self):
     get_days_statistics(datetime.utcnow())
     NodeFactory(category="project")  # makes 2 nodes
     NodeFactory(category="project")  # makes 2 more nodes
     latest = OSFWebsiteStatistics.objects.latest("date")
     get_days_statistics(datetime.utcnow(), latest)
     even_later = OSFWebsiteStatistics.objects.latest("date")
     nt.assert_equal(even_later.delta_projects, 4)
コード例 #5
0
ファイル: test_utils.py プロジェクト: kch8qx/osf.io
 def setUp(self):
     super(TestMetricsGetOSFStatistics, self).setUp()
     Node.remove()
     time_now = get_previous_midnight()
     NodeFactory(category="project", date_created=time_now)
     NodeFactory(category="project", date_created=time_now - timedelta(days=1))
     last_time = time_now - timedelta(days=2)
     NodeFactory(category="project", date_created=last_time)
     NodeFactory(category="project", date_created=last_time)
     get_days_statistics(last_time + timedelta(seconds=1))
     self.time = time_now + timedelta(seconds=1)
コード例 #6
0
 def setUp(self):
     super(TestMetricsGetOSFStatistics, self).setUp()
     Node.remove()
     time_now = get_previous_midnight()
     NodeFactory(category='project', date_created=time_now)
     NodeFactory(category='project',
                 date_created=time_now - timedelta(days=1))
     last_time = time_now - timedelta(days=2)
     NodeFactory(category='project', date_created=last_time)
     NodeFactory(category='project', date_created=last_time)
     get_days_statistics(last_time + timedelta(seconds=1))
     self.time = time_now + timedelta(seconds=1)
コード例 #7
0
 def test_time_now(self):
     get_days_statistics(datetime.utcnow())
     nt.assert_equal(OSFWebsiteStatistics.objects.count(), 1)
     nt.assert_equal(OSFWebsiteStatistics.objects.latest('date').projects, 2)